"""获取糗事百科一张热图:https://pic.qiushibaike.com/system/pictures/12311/123110600/medium/3ZOJEG74FO8RH0QY.jpgdate:2020-05-25
"""import requests
if __name__ == '__main__':url = 'https://pic.qiushibaike.com/system/pictures/12311/123110600/medium/3ZOJEG74FO8RH0QY.jpg'img_data = requests.get(url=url).contentwith open('04热图.jpg','wb') as fp:fp.write(img_data)
如报https警告,代码可修改如下:
"""获取糗事百科一张热图:https://pic.qiushibaike.com/system/pictures/12311/123110600/medium/3ZOJEG74FO8RH0QY.jpgdate:2020-05-25
"""import requests
if __name__ == '__main__':requests.packages.urllib3.disable_warnings()url = 'https://pic.qiushibaike.com/system/pictures/12311/123110600/medium/3ZOJEG74FO8RH0QY.jpg'headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3947.100 Safari/537.36'}img_data = requests.get(url=url, headers=headers, verify=False).contentwith open('04热图.jpg', 'wb') as fp:fp.write(img_data)