python编写子域名挖掘工具

import requests
import re
import threading
from urllib.parse import urlencode
#查询子域名
def scan_domain(domain,page):#域名,页数
    sub_domains = []
    url = "搜索语法"
    header={
        "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36"
    }
    resp = requests.get(url,headers=header)
    html_str = resp.text
    #数据解析
    pattern = re.compile(正则表达)
    results = re.findall(pattern,html_str)
    #print(results)
    for res in results:
        if "." in res:
            if "/" in res:
                sub_d = res.split('/')[0]
                sub_domains.append(sub_d)
    print(sub_domains)
    return sub_domains

if __name__ == '__main__':
    domain = input("domain:")
    pages = int(input("pages:"))
    #sub_domain = scan_domain(domain,pages)
    for page in range(pages):
        t = threading.Thread(target=scan_domain,args=(domain,page))
        t.start()

你可能感兴趣的:(python小脚本,python)