1 Star 2 Fork 1

MRlin / ks-python-devidng-utility

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
concurrent_map.py 574 Bytes
一键复制 编辑 原始数据 按行查看 历史
MRlin 提交于 2022-12-07 16:54 . 更新
import requests
import time
from multiprocessing.dummy import Pool
headers = {
'user-agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36'
}
urls = [
'https://sp1.baidu.com/',
'https://sp1.baidu.com/',
'https://sp1.baidu.com/',
'https://www.baidu.com/'
]
def get_url(url):
print('正在访问',url)
res = requests.get(url=url,headers=headers)
print('访问状态:',res.status_code)
# time.sleep(2)
while True:
pool = Pool(20)
pool.map(get_url,urls)
Python
1
https://gitee.com/p-kreas/ks-python-devidng-utility.git
git@gitee.com:p-kreas/ks-python-devidng-utility.git
p-kreas
ks-python-devidng-utility
ks-python-devidng-utility
master

搜索帮助