使用Python增加csdn的访问量
生活随笔
收集整理的這篇文章主要介紹了
使用Python增加csdn的访问量
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
雖然文章的質(zhì)量是訪問(wèn)量的關(guān)鍵,我們不能讓別人訪問(wèn),還不能自己給自己點(diǎn)贊么?發(fā)揮自己的主動(dòng)性,在每天電腦開(kāi)機(jī)時(shí),就訪問(wèn)一下自己的Blog,增加點(diǎn)點(diǎn)擊量。
當(dāng)然平臺(tái)也不是吃素的,會(huì)防刷點(diǎn)擊量的,所以每天只能增加一次。
?
1、如下為使用Python腳本的實(shí)現(xiàn)
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、增加開(kāi)機(jī)啟動(dòng)項(xiàng)(windows)
注意,這個(gè)腳本的打開(kāi)方式,選擇使用python3
?
總結(jié)
以上是生活随笔為你收集整理的使用Python增加csdn的访问量的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 电信江湖令
- 下一篇: extern C 在c 与 cxx间的使