python爬虫爬取百度图片

python爬虫-爬取百度图片(转)
#!/usr/bin/python
# coding=utf-8
# 作者 :Y0010026
# 创建时间 :2018/12/16 16:16
# 文件 :spider_04.py
# IDE :PyCharm

# 爬取百度图片(GET方式爬取Ajax数据)
import urllib2

url = 'http://image.baidu.com/search//acjson?tn=resultjson_com&ipn=rj&ct=201326592&is=&fp=' \
'result&queryWord=%E9%9D%92%E6%98%A5%E5%A6%B9%E5%AD%90%E5%9B%BE&cl=2&lm=-1&ie=utf-8&oe=' \
'utf-8&adpicid=&st=&z=&ic=&word=%E9%9D%92%E6%98%A5%E5%A6%B9%E5%AD%90%E5%9B%BE&s=&se=&tab=&width=' \
'&height=&face=&istype=&qc=&nc=&fr=&pn=30&rn=30&gsm=1e&1502192101260='

# 请求头描述信息
header = {
'User-Agent': 'Mozilla/5.0(WindowsNT6.1;rv:2.0.1)Gecko/20100101Firefox/4.0.1'
}
# 包装请求对象
requset = urllib2.Request(url, headers=header)
# 根据请求对象发送数据请求,获取服务器返回的响应对象
response = urllib2.urlopen(requset)
# 获取响应对象中的数据
content = response.read()
# 将获取的数据保存在文件中
with open('qing.json', 'w') as f:
f.write(content)
原文链接:https://www.cnblogs.com/huangjiaxiaoluobo/p/10126963.html
原文地址:https://www.cnblogs.com/xiaohai123/p/13577194.html