-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprobing.py
33 lines (27 loc) · 1.12 KB
/
probing.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import requests
from multiprocessing import Pool
requests.packages.urllib3.disable_warnings(requests.packages.urllib3.exceptions.InsecureRequestWarning)
from pandas import DataFrame
from os.path import join
maxprocessors=4
def readata(inputfile):
with open(inputfile,'r+') as file:
data=[x.split(',')[0] for x in file.read().splitlines()[1:]]
data=DataFrame(data,columns=["urls"])
return data
def active_urls(url):
try:
if requests.get(f"http://{url}",verify=False,timeout=2.50).status_code<400:
return url
except:
return
def writedata(data,urls,outputfile):
data["status"]=data["urls"].isin(urls).map({True:"Live",False:"Dead"})
data.sort_values(by=["status"],ascending=False).to_csv(outputfile,index=False)
def init_prob(filepath):
inputfile,outputfile=join(filepath,'subdomain.csv'),join(filepath,'probing.csv')
data=readata(inputfile)
with Pool(maxprocessors) as p:
checked_urls=p.map(active_urls,data["urls"].tolist())
writedata(data,checked_urls,outputfile)
print("\nThe data has been saved to probing.csv")