网络图片爬取和ip获取

网络图片的爬取和存储
import requests
path = "F:/photo.jpg"
url = "https://image.baidu.com/search/detail?ct=503316480&z=0&ipn=d&word=%E9%98%BF%E5%B0%94%E5%8D%91%E6%96%AF%E5%B1%B1&step_word=&hs=0&pn=2&spn=0&di=224730&pi=0&rn=1&tn=baiduimagedetail&is=0%2C0&istype=0&ie=utf-8&oe=utf-8&in=&cl=2&lm=-1&st=undefined&cs=2665302397%2C3120351625&os=2129687575%2C1384595567&simid=3457799197%2C435355632&adpicid=0&lpn=0&ln=1753&fr=&fmq=1580995673178_R&fm=&ic=undefined&s=undefined&hd=undefined&latest=undefined©right=undefined&se=&sme=&tab=0&width=undefined&height=undefined&face=undefined&ist=&jit=&cg=&bdtype=0&oriquery=&objurl=http%3A%2F%2Fcn.best-wallpaper.net%2Fwallpaper%2F1280x1024%2F1706%2FAlps-Italy-village-houses-trees-mountains-fields-beautiful-landscape_1280x1024.jpg&fromurl=ippr_z2C%24qAzdH3FAzdH3Fvg_z%26e3Bkjfp-owssrwrj6_z%26e3BgjpAzdH3FAsrf-Ipwsy-etssw2j-i57fjf-p6jjf-457gpwtgf-utjs1f-kjw7ptu7s-swg1fvwrj_8dbax8ad9_z%26e3Bip4s&gsm=2&rpstart=0&rpnum=0&islist=&querylist=&force=undefined"
r = requests.get(url)
r.status_code
with open(path,'wb') as f:
  f.write(r.content)
f.close()

IP地址归属地的自动查询
import requests
url = "http://m.ip138.com/ip.asp?ip="
r = requests.get(url + '202.204.80.112')
r.status_code


你可能感兴趣的:(python)