python脚本之访问网易博客

发布时间:2022-03-03 09:48:32 人气:257 作者:多测师

  这里show一个访问网易博客的python脚本吧,这是去年为了好玩在网上找的原型,去年已经可以在python2.6上work了的,现在在学习的是python3了,所以下面的是python3的代码,另外加上公司的网络都要设置代理才能访问外网,所以添加了代理的设置。

  BTW,经过测试,该脚本可以作为网易博客的顶贴器,貌似网易博客没有对同一个IP的多次访问记录做去重之类的处理。当然除了简单的测试之外,我并没有用这种程序来刷我的博客记录,我觉得这样也没意思。代码中visitTimesPerPage变量设置的是访问每个url的次数,要是设为1000次,则每个url都会访问1000遍。

python脚本之访问网易博客

  代码如下:

  #! /usr/bin/python3

  # -*- coding: utf-8 -*-

  '''

  Created on 2011-04-06

  @author: 笑遍世界

  '''

  import sys

  import threading

  import urllib.request

  urls = ["blog/static/16005312010101782448207/",

  "blog/static/16005312010111233057624/",

  "blog/static/16005312010111244548449/",

  ]

  visitTimesPerPage = 10

  def usage():

  print('Usage:', sys.argv[0], 'host')

  def main(argv):

  host = argv[1]

  if host == '':

  usage()

  sys.exit(2)

  else:

  for i in range(visitTimesPerPage):

  for url in urls:

  visitPageThread = VisitPageThread(url + str(i), host, url)

  visitPageThread.start()

  class VisitPageThread(threading.Thread):

  def __init__(self, threadName, host, url):

  threading.Thread.__init__(self, name = threadName)

  self.host = host

  self.url = url

  def run(self):

  url = self.host + self.url

  req = urllib.request.Request(url)

  req.set_proxy('companyname.com:911', 'http')

  #you may set you proxy here.

  try:

  doc = urllib.request.urlopen(req).read()

  print(doc)

  except Exception as e:

  print("urlopen Exception : %s" %e)

  if __name__=='__main__':

  sys.argv.append('http://ren**.blog.163.com/')

  main(sys.argv)

  以上内容为大家介绍了python脚本之访问网易博客,希望对大家有所帮助,如果想要了解更多Python相关知识,请关注多测师。https://www.e70w.com/xwzx/

返回列表
在线客服
联系方式

热线电话

17727591462

上班时间

周一到周五

二维码
线