就是说,爱美之心人皆有之
谁还不喜欢看美女了,今天就带你们采集外网小姐姐的绝美照片吧
第三方模块 需要安装 在cmd里面 进行 pip install requests / parsel
这是网址
python学习交流Q群:770699889 ###(yuan ma huo qu)
import requests
headers = {
'cookie': 'csrftoken=1fbccfe7be3950546f7138f25091d746; _routing_id="69be489d-566e-4ba3-9b0c-0101e5cc8a2e"; sessionFunnelEventLogged=1; g_state={"i_l":0}; _auth=1; _pinterest_sess=TWc9PSZEQ1FEMWt1S05WRTZJa1U1eFh6ZlpEdnc5OXRqdUlLZE9VemlNT3pZWEgwOFM3VDVNZkowcHVFSXRtai9LWWNXbjF3c3dPL05aYUNaeFc4RlpscTVJaVFQbUVaUllCKzNCTGY2OTFGWUdYZlJ5cHUwRUJxREJENnVCdlFpMWVYU3hiSUdaZElkRzBndEZ4VHB3VC9KK09Qd0RqbWYrcjRBbHZ4L2RGWW51NjdJMnBYQlhxV2RMdFZpNk1iQ1BwblNJWnVxQmNhclM4NFJkalpMU3hKWEsvUUlLdS8yMVNlK3JTUkZROEVtaGZkU3p6bElHd3JVdkJldUNTN1RISy9Qc3kyZmN5cmZBVk8veFZVNFVoSDZ4dkliK0NWSml0Z2ZhWU5mTUNMK0Jna0NMc3AwdkZZOXhHVC9qVVc0T05OTG1iUE5va09OY2xBMERBUDgvNXQzdnFyVVBVVnczNlhENnJjK3NYdFllZ3Y1bUhyaVBtcW8zS29RZHI0dDdvQUJUdzF0UU1idjNPb2w3UUZsaUpNcitXaU94c0ZzWldwdXBZTjJIcHVIb1Y5NmtmbUVIa09vOVFkKzRnMXZSZ2lFM0dZaktNSUtBNzdHQVMvVEgxaWhWcjJEc3FjMUF6QzdWU2tCNzVmYS9VNTVrV1FqeE5WbHV3QzRhRTlaZ0drVjNuVUwvSUNvc3hMUlNSZ2RwMzI4VUpoN0JndXN4QUNMR2lVa2xXRklJME9uNHBwd3VvMzM5a0ZjbHRXZVVobXhxUTdtdDdrR3dyKzh1dWlITHRISlhuM0U2RnZRLzhzS2lXYUxCbWJxMlRlYk5ZNnNQK2o1WlhIWVNTQzJOdk5Qc0wwdllCMWhHQ3FmOTJ4aFRjWkh5ZUJvYk0xS1J0Vy80UUpWQXF4bGdVOElCRm1lM2NBNVB5ejlNY0ZTTE9Jc25GM09XNW9jekIyd1NRMFJ2Y1NhU2kySDJFRGI5SmIzWWFiK01DVEN5ZmRtdlJzb0p5Y2NxeTdsTFE0MnlPc0RlT1hlRDg4RzI0Qi9kREJGMlJmZHBnPT0mSlFoTnZSdXVhQXo1UWt0UmVxRGZxYWtlWDlJPQ==; _b="AWhINcS3C8VBV4G03jvnkIaZom1KWxg8XVIgP4mExnEZvkkYv/AuTCOEObC+45sj5iQ="; cm_sub=none',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36'
}
def get_next(bookmark):
url = 'https://../resource/UserHomefeedResource/get/?source_url:/&{"options":{"field_set_key":"hf_grid","in_nux":false,"in_news_hub":false,"prependPartner":false,"static_feed":false,"bookmarks":["'+bookmark+'"],"no_fetch_context_on_resource":false},"context":{}}&_=1664260179856'
因链接太长,平台又不能出现网站链接
所以上面得代码我就把它删了,大家可以按照下面得图片把它添加一下
python学习交流Q群:770699889 ###
json_data = requests.get(url, headers=headers).json()
bookmark = json_data['resource_response']['bookmark']
for data in json_data['resource_response']['data']:
img_url = data['images']['orig']['url']
print(img_url)
img_name = img_url.split('/')[-1]
img_data = requests.get(img_url).content
with open(f'img/{img_name}', mode='wb') as f:
f.write(img_data)
get_next(bookmark)
get_next('Y2JVSG80T1ZFd1JrSlJhMFpDVVZWR1FsRlhPVUpSVjJSQ1VWVkdXbFJxYkhaa2EwWlVVVEJHUWxKRlJrSlJWVVpJVVZjNVFsRnJaM1pNZVRoMlRIazRka3d5ZUZWUk1FWkNVakJHUWxGVlJraFZXRTVDVVc1a1FsRlZSa0pOU0doUFlXeHJkMVJYY0Zwa01ERlZXVE53VUZKRmF6QlJNbVJDVTFkWmRreDVPSFpNZVRoMlN6RmFUbEZZZUcxT1JHTTBXbXBXYWs1cVdtMVphbXQ0VFcxTk5VNUhXVFZaYWxKdFRrZEpNVTFxVFhwWlYwWm9XWHBGTWxsWFdtcGFWRnBwVGtkUk1VMHlVWGxPUjBsNVdWZE5NMXBFUW1oYVJGazFUa1JWTWs1dFZUSm1SVFZHVmpOM1BRPT18VUhvNU5WUlhWbHBNTTBaTlZsTTRkbHA2TVdaTmFsWm1URlJHT0ZwWFNURlBSMXB0VFVkRk1VNTZaekZQUkVreldXcENiVmxxVm10YWFsSnRXV3BCZWxsdFdUUk9lbFUwV2tSb2FWbFhVVEZaYWtsNVRVZFZlRTR5V21sTlJFSnJXbFJGTWxsVVdteE5lbFpyVFcxRmVVNXVlRTlTVm1RNHwwYmNhMjZkNTdmYTUzMzA0MzEzM2Y1Yzg1OGZhZjY5NjMwNTc3MDUzNGRjM2FhNDhkNDQ4ZWIzNGYxODQ5YTA4fE5FV3w=')
【Python案例】图片采集
接下来欣赏一下我们的成果吧
都是美照!
好啦,今天的分享到这里就结束了 ~
如果需要视频学习的可以在b站搜索 :Python小圆 / ka-爆浆麻薯团子
对文章有问题的,或者有其他关于python的问题,可以在评论区留言或者私信我哦
觉得我分享的文章不错的话,可以关注一下我,或者给文章点赞(/≧▽≦)/