python爬虫-urllib2库的有一些高级用法

2015-06-13 0 891
python爬虫-urllib2库的有一些高级用法
import urllib
import urllib2
url = 'www.abc.com'
form = {"name": '1234', "password": '4321'}
data = urllib.urlencode(form)  # 将字典以url形式编码
header = {'User-Agent': 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)',  # 浏览器头
          'Referer': 'http://www.abc.com'  # 反盗链
          }
request = urllib2.Request(url, data, header)
response = urllib2.urlopen(request)
print response.read()

遇见资源网 python python爬虫-urllib2库的有一些高级用法 http://www.ox520.com/15443.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务