爬虫仅限于知识学习,本代码不得用于任何商业活动侵权,如有不适,请联系博主进行修改或者删除。
目标链接:https://s.weibo.com/
目标内容:
首先按住F12或者鼠标右键打开控制台,并且刷新一下,找到目标接口
接着点击网络,查找对应的链接
Copy刚刚查到的的Crul链接
点击Copy as cUrl(bash)内容→将复制的内容到工具转化网站:https://tool.lu/curl/ ,然后点击生成Python
测试复制出来的代码是否能够正常运行
import requests
cookies = {
'SUBP': '0033WrSXqPxfM72-Ws9jqgMF55529P9D9W5-JJ8oga5ydhsGdj6kPdLS',
'SINAGLOBAL': '2419051227691.933.1677488001840',
'SUB': '_2AkMT3bncf8NxqwJRmfwSz2jkbYx1yA3EieKlgUgHJRMxHRl-yT9vqnwztRB6OF2XMwOkUv-6XZ3uR9ZU--4KakhG2S91',
'UOR': ',,www.baidu.com',
'_s_tentry': '-',
'Apache': '894723423235.0753.1693625742494',
'ULV': '1693625742512:3:1:2:894723423235.0753.1693625742494:1693462317344',
}
headers = {
'authority': 's.weibo.com',
'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
'accept-language': 'zh-CN,zh;q=0.9',
'cache-control': 'no-cache',
# Requests sorts cookies= alphabetically
# 'cookie': 'SUBP=0033WrSXqPxfM72-Ws9jqgMF55529P9D9W5-JJ8oga5ydhsGdj6kPdLS; SINAGLOBAL=2419051227691.933.1677488001840; SUB=_2AkMT3bncf8NxqwJRmfwSz2jkbYx1yA3EieKlgUgHJRMxHRl-yT9vqnwztRB6OF2XMwOkUv-6XZ3uR9ZU--4KakhG2S91; UOR=,,www.baidu.com; _s_tentry=-; Apache=894723423235.0753.1693625742494; ULV=1693625742512:3:1:2:894723423235.0753.1693625742494:1693462317344',
'pragma': 'no-cache',
'sec-ch-ua': '"Chromium";v="116", "Not)A;Brand";v="24", "Google Chrome";v="116"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'sec-fetch-dest': 'document',
'sec-fetch-mode': 'navigate',
'sec-fetch-site': 'none',
'sec-fetch-user'<