微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用Python增加csdn的访问量

虽然文章的质量是访问量的关键,我们不能让别人访问,还不能自己给自己点赞么?发挥自己的主动性,在每天电脑开机时,就访问一下自己的Blog,增加点点击量。

当然平台也不是吃素的,会防刷点击量的,所以每天只能增加一次。

 

1、如下为使用Python脚本的实现

python 3.0 , 安装requests包

 

import requests
import time

main_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 ID

time.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.")
        break

    num += 1
    # Find URL
    pos_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

 

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐