#coding:utf-8
import urllib2
ua_headers={
"User-Agent":"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0"
}
request=urllib2.Request("http://baidu.com/",headers=ua_headers)
response=urllib2.urlopen(request)
html=response.read()
print html
print response.getcode() #返回响应码
print response.geturl() #返回实际url
print response.info() #返回服务器响应的报头
python urllib2模拟浏览器请求 爬虫
最新推荐文章于 2024-05-26 00:43:01 发布