import os, requests, time
from multiprocessing.dummy import Pool as ThreadPool
from multiprocessing import Pool
import threading
import sys
from colorama import Fore, Style
import requests, json
from colorama import Fore, init, Style
init(autoreset=True)
import requests
from bs4 import BeautifulSoup as bs
import pandas as pd


bl = Fore.BLUE
wh = Fore.WHITE
gr = Fore.GREEN
red = Fore.RED
res = Style.RESET_ALL
yl = Fore.YELLOW
cc = Fore.CYAN
cw = Fore.LIGHTBLUE_EX
gre = Fore.LIGHTGREEN_EX
ex = Fore.MAGENTA


def screen_clear():
    _ = os.system('cls')


headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36'
}
def reverse(ip):
    url = 'https://viewdns.info/reverseip/?host='+ip+'&t=1'
    soup = bs(requests.get(url, headers=headers).text, 'html.parser')
    table = soup.select_one('table[border="1"]')
    df = pd.read_html(str(table), header=0)[0]
    try:
        if "Domain" in df:
            print(df)
            df.to_csv('some_websites.csv')
        else:
            print(f' not Dmonain in {ip} \n')
    except:
        pass

def filter(ip):
    try:
       reverse(ip)
    except:
       pass


def main():
    list = input(' ips ')
    ip = open(list, 'r').readlines()
    try:
        ThreadPool = Pool(50)
        ThreadPool.map(filter, ip)
        ThreadPool.close()
        ThreadPool.join()
    except:
        pass


if __name__ == '__main__':
    screen_clear()
    main()