Created
August 9, 2017 22:21
-
-
Save jizhang/024af8e0570b1e394239855d2c9dd40d to your computer and use it in GitHub Desktop.
Crawl CSDN Blog's Page Views
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import re | |
import urllib2 | |
import datetime | |
html = urllib2.urlopen('http://blog.csdn.net/zjerryj').read() | |
mo = re.search(r'访问:<span>(\d+)次</span>', html) | |
with open('/home/jizhang/csdn.log', 'a') as f: | |
f.write('%s,%s\n' % (datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'), mo.group(1))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment