使用Python增加csdn的访问量
生活随笔
收集整理的這篇文章主要介紹了
使用Python增加csdn的访问量
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
雖然文章的質量是訪問量的關鍵,我們不能讓別人訪問,還不能自己給自己點贊么?發揮自己的主動性,在每天電腦開機時,就訪問一下自己的Blog,增加點點擊量。
當然平臺也不是吃素的,會防刷點擊量的,所以每天只能增加一次。
?
1、如下為使用Python腳本的實現
python 3.0 , 安裝requests包
?
import requests import timemain_url = "https://blog.csdn.net/u012573878" # Attention, use your ID match_sub = "<div class=\"article-item-box csdn-tracking-statistics\"" match_url = "https://blog.csdn.net/u012573878/article/details/" # Attention, use your IDtime.sleep(30) # Wait network connect, Maybe use ping check.# Real work Begin. t1 = time.time() http_header = {'user-agent': 'wxytest'+str(t1)} rsp =requests.get(main_url, headers=http_header) rsp.encoding = "utf-8"out_txt = rsp.text # print("Receive %d from http server.\nMessage is:\n%s" %(len(out_txt), out_txt))begin = 0 urls = {} num = 0 while True:# Find a Block contain url and title.pos_s = out_txt.find(match_sub, begin)if -1 == pos_s:print("Match sub error.")breaknum += 1# Find URLpos_s = out_txt.find(match_url, pos_s)pos_e = out_txt.find("\"", pos_s)tmp_url = out_txt[pos_s:pos_e]# Find title.pos_s = out_txt.find("</span>", pos_e)pos_e = out_txt.find("</a>", pos_s)tmp_title = out_txt[pos_s+len("</span>"):pos_e]# print("%d %s %s" %(num, tmp_title , tmp_url))urls[tmp_title] = tmp_url# Next loop now.begin = pos_e# Access blog one by one for key in urls.keys():print("Access %s:%s............." %(key, urls[key]))tmp_rsp = requests.get(urls[key], headers=http_header)print("Result : ", tmp_rsp)t2 = time.time() print("Good ........................Use time %s, increase %d visits." %(str(t2-t1)[:5], num)) input("Enter Any key to Exit...")2、增加開機啟動項(windows)
注意,這個腳本的打開方式,選擇使用python3
?
總結
以上是生活随笔為你收集整理的使用Python增加csdn的访问量的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 电信江湖令
- 下一篇: extern C 在c 与 cxx间的使