Python 站长工具端口扫描爬取
import requests,timeimport random
from bs4 import BeautifulSoup
import re
import threading
def ports(hostm,port):
url = 'http://tool.chinaz.com/port/'
headers = {
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36'
}
data = {
'host':hostm,
'port':port
}
response = requests.post(url,headers=headers,data=data).text
encode = BeautifulSoup(response,'html.parser').findAll('input',{"id":"encode"}).get('value')
data['encode'] = encode
callback = "jQuery113"+str(int(random.random()*100000000000000000))+'_'+str(int(time.time()*1000))
params = {
'callback':callback,
't':'port'
}
url = 'http://tool.chinaz.com/iframe.ashx'
response = requests.post(url,headers=headers,data=data,params=params).text
response = re.sub(callback,'',response)
print(re.findall(r"'(.*?)'",response))
return re.findall(r"'(.*?)'",response)
if __name__=="__main__":
for i in range(0,1000):
# print(ports('baidu.com', str(i)))
threading.Thread(target=ports,args=('baidu.com', str(i))).start()
你为什么要去采集别的结果多慢,自己写多好? 无名小银 发表于 2021-5-22 07:56
你为什么要去采集别的结果多慢,自己写多好?
就是写着玩玩 学习一下,谢谢了 磨时间的好游戏 go学习学习一下,谢谢
结果不甚理想啊! jamescookers988 发表于 2021-5-22 17:36
结果不甚理想啊!
什么问题 lichen218 发表于 2021-5-23 10:13
什么问题
list index out of range,如图所示啊! 学习学习一下,谢谢
页:
[1]