使用python刷访问量的示例代码

作者:shiguanggege 时间:2023-11-09 12:55:30 

python刷CSDN访问量


import requests
import re
import time
payload = ""
# 请求头
headers = {
 "Accept": "*/*",
 "Accept-Encoding": "gzip, deflate, br",
 "Accept-Language": "zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3",
 "Cookie": "l=AurqcPuigwQdnQv7WvAfCoR1OlrRQW7h; isg=BHp6mNB79CHqYXpVEiRteXyyyKNcg8YEwjgLqoRvCI3ddxqxbLtOFUBGwwOrZ3ad; thw=cn; cna=VsJQERAypn0CATrXFEIahcz8; t=0eed37629fe7ef5ec0b8ecb6cd3a3577; tracknick=tb830309_22; _cc_=UtASsssmfA%3D%3D; tg=0; ubn=p; ucn=unzbyun; x=e%3D1%26p%3D*%26s%3D0%26c%3D0%26f%3D0%26g%3D0%26t%3D0%26__ll%3D-1%26_ato%3D0; miid=981798063989731689; hng=CN%7Czh-CN%7CCNY%7C156; um=0712F33290AB8A6D01951C8161A2DF2CDC7C5278664EE3E02F8F6195B27229B88A7470FD7B89F7FACD43AD3E795C914CC2A8BEB1FA88729A3A74257D8EE4FBBC; enc=1UeyOeN0l7Fkx0yPu7l6BuiPkT%2BdSxE0EqUM26jcSMdi1LtYaZbjQCMj5dKU3P0qfGwJn8QqYXc6oJugH%2FhFRA%3D%3D; ali_ab=58.215.20.66.1516409089271.6; mt=ci%3D-1_1; cookie2=104f8fc9c13eb24c296768a50cabdd6e; _tb_token_=ee7e1e1e7dbe7; v=0",
 "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64;` rv:47.0) Gecko/20100101 Firefox/47.0"
}
# 获得文章列表urls
def getUrls(url):
# 发送请求
 resp = requests.request("GET", url, data=payload, headers=headers)
 #设置解码方式
 resp.encoding=resp.apparent_encoding
 #这里会用设置的解码方式解码
 html_source = resp.text
 # 正则表达式,取出网页中的url链接(一些寻找注入点的工具也是这么做出来的)
 urls = re.findall("https://[^>\";\']*\d",html_source)
 new_urls=[]
 for url in urls:
   if 'details' in url:
     if url not in new_urls:
       new_urls.append(url)
 return new_urls
urls = getUrls("主页地址")
while True:
 for url in urls:
   requests.request("GET", url, data=payload, headers=headers)
   print(url, "Ok")
   time.sleep(3)
 time.sleep(3)

python刷博客园访问量 


import requests
import time
import re
from lxml import etree
headers = {
 'referer':'https://i.cnblogs.com/posts',
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36"
}
proxy = {
'http':'xxxx:xxx',#可以使用代理
}
def get_urls(url):
 ret = requests.get(url=url,headers = headers)
 ret.encoding='utf-8'
 urls = re.findall('href="https://www.cnblogs.com/shiguanggege/p/(.*?).html" rel="external nofollow" ',ret.text) #正则条件根据博客地址修改
 return urls
urls = []
for url in [f'https://www.cnblogs.com/shiguanggege/default.html?page={i}' for i in range(1,10)]: #url根据自己博客地址修改
 links = get_urls(url)
 for link in links:
   l = f'https://www.cnblogs.com/shiguanggege/p/{link}.html' #这个地址也是根据博客地址修改
   if l not in urls:
     urls.append(l)
while True:
 for i in urls:
   requests.get(url=i,proxies=proxy)
   print(i,'ok')
   time.sleep(1)
 time.sleep(3)

来源:https://blog.csdn.net/shiguanggege/article/details/114388988

标签:python,刷访问量
0
投稿

猜你喜欢

  • go语言中的return语句

    2024-05-28 15:22:09
  • Python+Turtle绘制可爱的可达鸭

    2021-06-18 10:20:29
  • Python使用Rich type和TinyDB构建联系人通讯录

    2023-07-13 10:33:22
  • PHP中phar包的使用教程

    2023-11-09 19:55:52
  • Python嵌套函数,作用域与偏函数用法实例分析

    2022-12-03 08:46:15
  • struts2+jsp+jquery+Jcrop实现图片裁剪并上传实例

    2023-06-19 16:30:10
  • PHP字符串的编码问题的详细介绍

    2024-05-02 17:17:15
  • 如何基于matlab相机标定导出xml文件

    2023-01-29 17:52:59
  • Python实现暴力破解有密码的zip文件的方法

    2023-11-22 22:48:40
  • Oracle 创建用户及数据表的方法

    2009-09-26 18:25:00
  • 解决python 输出是省略号的问题

    2021-01-09 13:38:49
  • 一篇文章弄懂Python中的内建函数

    2023-01-18 00:36:36
  • php下intval()和(int)转换使用与区别

    2023-06-11 14:09:54
  • 图文详解OpenCV中光流以及视频特征点追踪

    2022-12-30 01:45:08
  • Python语言实现获取主机名根据端口杀死进程

    2023-07-01 10:05:58
  • 对python操作kafka写入json数据的简单demo分享

    2023-05-04 21:24:08
  • js判断设备是否为PC并调整图片大小

    2024-05-02 16:12:22
  • python实现网页自动签到功能

    2024-01-03 00:13:14
  • python通过邮件服务器端口发送邮件的方法

    2021-10-18 02:34:09
  • 浅谈django 模型类使用save()方法的好处与注意事项

    2021-05-17 10:43:59
  • asp之家 网络编程 m.aspxhome.com