发布时间:2025-12-11 02:45:05 浏览次数:2
python 3.6
pycharm
requests
pipinstallrequests
importrequestsurl='https://www.duitang.com/napi/vienna/feed/list/by_common/?start=0&limit=18'headers={'User-Agent':'Mozilla/5.0(WindowsNT10.0;WOW64)AppleWebKit/537.36(KHTML,likeGecko)Chrome/84.0.4147.105Safari/537.36'}response=requests.get(url=url,headers=headers)html_data=response.json()dit=html_data['data']['object_list']foriindit:img_data=i['atlas']['blogs']forjinimg_data:img_url=j['photo']['path']name=img_url.split('_')[-1]img_url_response=requests.get(url=img_url,headers=headers)withopen('G:\\python\\demo\\案例\\堆糖网\\图片\\'+name,mode='wb')asf:f.write(img_url_response.content)print(img_url)关于python怎么爬取堆糖网每日精选图片就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。