Python刷博客简易版

刷博客浏览量

import time
import requests
import datetime

article_id_list = [“104451026”, “104061943”, “102649428”, “100637109”, “100186409”, “81750818”, “85873527”,
“81211908”, “104467649”]

code = 200
while code == 200:
for key in article_id_list:
url = “https://blog.csdn.net/weixin_42792621/article/details/{id}” .format(id=key)
headers = {
“authority”: “blog.csdn.net”,
“method”: “GET”,
“path”: “/weixin_42792621/article/details/{id}”,
“scheme”: “https”,
“accept”: “text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.9”,
“accept-encoding”: “gzip, deflate, br”,
“accept-language”: “zh-CN,zh;q=0.9”,
“cache-control”: “max-age=0”,
“cookie”: “此处自己调浏览器开发者界面,抓包,拿自己当前cookies就行”,
“referer”: “https://mp.csdn.net/console/article”,
“user-agent”: “Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36”
}
headers [“path”] = headers [“path”].format(id=key)
response = requests.get(url=url , headers=headers )
print(new_url)
print(new_headers[“path”])
print(response.status_code, key, datetime.datetime.now().strftime(’%Y-%m-%d %H:%M:%S’))
code = response.status_code
time.sleep(60)
del new_url, new_headers

解释以上代码重点注意项:
1. Cookies 自己抓包粘进去就行,刷个浏览不用搞那么麻烦
2. Headers里 path 属性要动态构造自己文章ID
3. URL 自己动态构造
4. 一定要睡一段时间在请求,慢慢刷,别急,太快单IP没效果
5. article_id_list 这东西是文章Id,看自己文章URL地址
6. Headers里 path 属性记得改成自己抓包的
在这里插入图片描述
这段代码随便改改放到服务器就行

nohup python3 csdn_pv.py &
挂到后台慢慢刷就行,不用管-。-

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值