BLOG
Enjoy when you can, and endure when you must.
DEC 12, 2013/Python
抓站进行曲
抓站挺好玩的(不过对方心情可就不好说了= =),能够满足某些有趣的需求。Python标准库中的urllib2(在Python3中拆分成urllib.request和urllib.error,这里以Python2作为示例)也很善于做这个事。对于一般的网站来说,请求并获得网页内容是很简单的,借助于urllib2.urlopen两行代码就能搞定:>>> import urllib2 >>> res = urllib2.urlopen('http://www.dannysite.com/blog/...
1