如何利用python刷访问量


当前第2页 返回上一页

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

#-*- coding=utf-8 -*-

 

import urllib2

import codecs

import re

 

csdn_url = "http://blog.csdn.net/walegahaha"

blog_url = ["http://blog.csdn.net/walegahaha/article/details/51945421",

       "http://blog.csdn.net/walegahaha/article/details/51867904",

       "http://blog.csdn.net/walegahaha/article/details/51603040",

       "http://blog.csdn.net/walegahaha/article/details/50938260",

       "http://blog.csdn.net/walegahaha/article/details/50884627",

       "http://blog.csdn.net/walegahaha/article/details/50877906",

       "http://blog.csdn.net/walegahaha/article/details/50868049",

       "http://blog.csdn.net/walegahaha/article/details/50533424",

       "http://blog.csdn.net/walegahaha/article/details/50504522",

       "http://blog.csdn.net/walegahaha/article/details/50489053",

       "http://blog.csdn.net/walegahaha/article/details/50471417",

       "http://blog.csdn.net/walegahaha/article/details/50464531",

       "http://blog.csdn.net/walegahaha/article/details/50452959",

       "http://blog.csdn.net/walegahaha/article/details/50435986",

       ]

 

class CSDN(object):

    def __init__(self):

        self.csdn_url = csdn_url

        self.blog_url = blog_url

        self.headers =  {'User-Agent':'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6',} 

 

    def openCsdn(self):

        req = urllib2.Request(self.csdn_url, headers = self.headers)

        response = urllib2.urlopen(req)

        thePage = response.read()

        response.close()

        pattern = "访问:<span>(\d+)次</span>"

        number = ''.join(re.findall(pattern, thePage))

        print number

 

    def openBlog(self):

        for i in range(len(self.blog_url)):

            req = urllib2.Request(self.blog_url[i], headers = self.headers)

            response = urllib2.urlopen(req)

            response.close()

 

     

for i in range(500):

    print i

    csdn = CSDN()

    csdn.openCsdn()

    csdn.openBlog()

    csdn.openCsdn()

【推荐课程:Python视频教程】

以上就是如何利用python刷访问量的详细内容,更多文章请关注木庄网络博客!!

返回前面的内容

相关阅读 >>

pandas series对象的常见属性有哪些?

怎么把字符串解析成浮点数或者整数

Python守护进程的实现

Python字符串拼接方法总结

Python读写docx文件的方法

简单易学的Python语言,黑客也喜欢她

Python中n是什么意思?

盘点Python中的常用术语

Python中如何将列表中的字符串连接成一个长路径的实例

字典的什么方法返回字典的键列表

更多相关阅读请进入《Python》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...