美文网首页
图片URL打开乱码,如何抓取

图片URL打开乱码,如何抓取

作者: 盖码范 | 来源:发表于2021-01-21 11:00 被阅读0次

抓包显示是乱码

image.png

抓取

保存二进制格式即可

#!/usr/bin/env python  
# encoding=utf-8  

import requests
headers = {
    'Host': 'zimaoda.com',
    'Connection': 'keep-alive',
    'Accept': 'image/avif,image/webp,image/apng,image/*,*/*;q=0.8',
    'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36',
    'Accept-Encoding': 'gzip, deflate',
    'Accept-Language': 'zh-CN,zh;q=0.9'
}
url = 'http://zimaoda.com/index/loginValCode'
req = requests.get(url = url,headers = headers)
text = req.content   # 二进制数据
with open('a.png', 'wb') as f:
    f.write(text)

相关文章

网友评论

      本文标题:图片URL打开乱码,如何抓取

      本文链接:https://www.haomeiwen.com/subject/alprzktx.html