Python 爬虫学习记录
Python 版本 2.7.5
1.简单例子
使用urllib2获取html内容
import urllib2
url = 'http://www.baidu.com'
response = urllib2.urlopen(url)
html = response.read()
print html
还可以使用Request对象来请求,产生相同的结果。
import urllib2
url = 'http://www.sina.com'
req = urllib2.Request(url)
response = urllib2.urlopen(req)
html = response.read()
print html
2.