import requests,re import urllib3 def title(): print('+------------------------------------------') print('+ \033[36mDescribe: cmd下直接运行iippcc.py即可 \033[0m') print('+ \033[36m第一个输出内容,例 >>> 111.11.22.0/24 \033[0m') print('+ \033[36m第二个输出内容,例 >>> 要查询域名的相同字符,比如www.baidu.com中的baidu \033[0m') print('+ \033[36mC段地址保存在同级目录下的ipC.txt文件中 \033[0m') print('+ \033[36m域名链接保存在link.txt文件中 \033[0m') print('+------------------------------------------') def ipC(ip): headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0) Geocko/20100101 Firefox/60.0'} url = 'https://chapangzhan.com/' + ip resp = requests.get(url, headers=headers, verify=False) ipdate = re.findall('<a href="(.+?)"', resp.text) for ip1 in ipdate: if 'https://ipchaxun.com/' in ip1: new_ip = ip1.replace("https://ipchaxun.com/", "").rstrip("/") print(new_ip) with open(r'ipC.txt', 'a+') as f: f.write(new_ip + '\n') f.close() def link(keywords): headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0) Geocko/20100101 Firefox/60.0'} for ip in open('ipC.txt'): ip = ip.replace('\n', '') url = 'https://ipchaxun.com/' + ip resp = requests.get(url, headers=headers, verify=False) links = re.findall('<a href="(.+?)"', resp.text) for link in links: if keywords in link: link = link.strip("/") new_link = 'http://' + link print(new_link) # with open(r'link.txt', 'a+') as f: # f.write(new_link + '\n') # f.close() if __name__ == '__main__': urllib3.disable_warnings() title() ip = input('+ \033[35m请输入要查询的C段$:\033[0m') ipC(ip) keywords = input('+ \033[35m请输入域名中的关键字$:\033[0m') link(keywords)
chapangzhan.com爬C段域名脚本
于 2023-06-07 15:44:22 首次发布