废话不多说直接上代码
1.爬取千图网图片
import requests
url="https://pic.qiantucdn.com/58pic/26/77/29/auto_82h58PICFX3Vp1f58PIC9f44H_PIC2018.jpg"
headers={"Origin":"http://www.58pic.com","Referer":
"https://www.58pic.com/newpic/26772982.html",
"User-Agent"
:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1"}
response =requests.get(url,headers=headers)
img = response.content
with open( './f.jpg','wb' ) as f:
f.write(img)
print("图片爬取成功")
2.爬取 花瓣网图片
# coding:utf-8
'''
Created on 2016年8月16
@author: FangLiang
'''
import urllib.request
import re
###