Python 爬虫自动访问点击刷CSDN博客文章阅读量

一段小代码,可以帮助自动刷CSDN阅读量,感兴趣的朋友可以复制代码,然后把自己博客文章的URL修改一下就可以了,两个都修改之后可以使用了,帮助那些有需要的人

 

# 导入需要用到的库
import requests
import lxml
import random
import time
from lxml import etree
headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36"} # 可以通过抓包工具获取,模拟浏览器
proxy={'http':'109.197.188.12:8080'} # 代理的IP,也可以自己在网上找
while True:
    # 要刷的文章
    url1='https://blog.csdn.net/hubingzhong/article/details/81612271'
    url2='https://blog.csdn.net/hubingzhong/article/details/81587863'
    url3='https://blog.csdn.net/hubingzhong/article/details/81277232'
    url4='https://blog.csdn.net/hubingzhong/article/details/81277220'
    url5='https://blog.csdn.net/hubingzhong/article/details/81277190'
    url6='https://blog.csdn.net/hubingzhong/article/details/81277150'
    url7='https://blog.csdn.net/hubingzhong/article/details/82469986'

    Url=[url1,url2,url3,url4,url5,url6,url7]
    url=random.choice(Url) # 随机随机访问上面的文章
    print(url,"*"*30)
    time.sleep(0.6) # 设置访问的时间
    response=requests.get(url,headers=headers,proxies=proxy).content.decode('utf-8')
    mytree=lxml.etree.HTML(response)
    csdnlist=mytree.xpath('//div[@class="article-list"]/div')
    for i in csdnlist:
        try:
            iUrl=i.xpath('./h4/a/@href')[0]

        except:
            response = requests.get(url=iUrl, headers=headers, proxies=proxy).content.decode('utf-8')
            time.sleep(0.8)
            # 和上面一样的随机访问其他的文章
            urla = 'https://blog.csdn.net/hubingzhong/article/details/81277125'
            urlb = 'https://blog.csdn.net/hubingzhong/article/details/81277080'
            urlc = 'https://blog.csdn.net/hubingzhong/article/details/81211221'
            urld = 'https://blog.csdn.net/hubingzhong/article/details/81277131'
            URL = [urla, urlb, urlc, urld]
            urll = random.choice(URL)
            response1=requests.get(url=urll,headers=headers,proxies=proxy).content.decode('utf-8')
            # print(response1)
            # print(response)
            print(urll,"$"*30)
            print(iUrl,"@"*30)

你可能感兴趣的:(Python 爬虫自动访问点击刷CSDN博客文章阅读量)