安装requests
pip install requests
启动代码
import requests
import random
def get_html(html_url):
headers = {
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36'
}
response = requests.get(url=html_url, headers=headers)
return response
url_data = [
"https://blog.csdn.net/weixin_37474682/article/details/119741032",#【李宏毅深度学习CP1-2】(task1)机器学习简介
"https://blog.csdn.net/weixin_37474682/article/details/119762765",# 使用rocketmq,rocketmq-client-python的api开发rocketmq生产者和消费者
"https://blog.csdn.net/weixin_37474682/article/details/119765401",#【python pypinyin】汉语拼音字典切换方法
"https://blog.csdn.net/weixin_37474682/article/details/119785984",#【李宏毅深度学习CP3-4】(task2)回归
"https://blog.csdn.net/weixin_37474682/article/details/119809428",# python redis 小白入门教程
"https://blog.csdn.net/weixin_37474682/article/details/119843684",# VSCode 新建python虚拟环境
"https://blog.csdn.net/weixin_37474682/article/details/119855092",# 【牛客网华为机试】HJ1 字符串最后一个单词的长度
"https://blog.csdn.net/weixin_37474682/article/details/119855440",# 【牛客网华为机试】HJ2 计算某字母出现次数
"https://blog.csdn.net/weixin_37474682/article/details/119878441",# 【牛客网华为机试】HJ3 明明的随机数
"https://blog.csdn.net/weixin_37474682/article/details/119880358",# 【牛客网华为机试】HJ4 字符串分隔
"https://blog.csdn.net/weixin_37474682/article/details/119898691",# 【牛客网华为机试】HJ5 进制转换
"https://blog.csdn.net/weixin_37474682/article/details/119899324",# 【牛客网华为机试】HJ6 质数因子
"https://blog.csdn.net/weixin_37474682/article/details/119921421",# 【牛客网华为机试】HJ7 取近似值
"https://blog.csdn.net/weixin_37474682/article/details/119921505",# 【牛客网华为机试】HJ8 合并表记录
"https://blog.csdn.net/weixin_37474682/article/details/119935044",# 【小白入门】用Python增加知乎文章阅读量
"https://blog.csdn.net/weixin_37474682/article/details/119943208",# 【牛客网华为机试】HJ9 提取不重复的整数
"https://blog.csdn.net/weixin_37474682/article/details/119943251",# 【牛客网华为机试】HJ10 字符个数统计
"https://blog.csdn.net/weixin_37474682/article/details/119960868",# 【牛客网华为机试】HJ11 数字颠倒
"https://blog.csdn.net/weixin_37474682/article/details/119967058",# 【牛客网华为机试】HJ12 字符串反转
"https://blog.csdn.net/weixin_37474682/article/details/119967224",# 【牛客网华为机试】HJ13 句子逆序
"https://blog.csdn.net/weixin_37474682/article/details/119967404",# 【牛客网华为机试】HJ14 字符串排序
]
import time
while True:
try:
url = random.choice(url_data)
get_html(url)
time.sleep(10)
except:
time.sleep(60)