1. 接口鉴权

微博的内容大部分接口是需要鉴权的,主要是针对cookies中的SUBP

但是移动端的接口可以匿名访问,不做鉴权限制,但是数据返回的可能不全,但在不要求数据精度的情况下,不失为一个好的选择;

以下分享几个接口

2. 免鉴权的接口

1. 获取用户的微博_无 since_id 参数(一般作为入口)

curl --location 'https://m.weibo.cn/api/container/getIndex?luicode=10000011&lfid=100103type%3D1%26q%3D%E5%8D%88%E5%90%8E&type=uid&value=1253846303&containerid=1076031253846303' \
--header 'sec-ch-ua: "Chromium";v="124", "Google Chrome";v="124", "Not-A.Brand";v="99"' \
--header 'X-XSRF-TOKEN: d13f16' \
--header 'sec-ch-ua-mobile: ?0' \
--header 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36' \
--header 'Accept: application/json, text/plain, */*' \
--header 'MWeibo-Pwa: 1' \
--header 'Referer: https://m.weibo.cn/u/1253846303?t=&luicode=10000011&lfid=100103type%3D1%26q%3D%E5%8D%88%E5%90%8E' \
--header 'X-Requested-With: XMLHttpRequest' \
--header 'sec-ch-ua-platform: "Windows"' \
--header 'Cookie: WEIBOCN_FROM=1110106030; _T_WM=3251c71cea1ed12d7fc32617409daab6'

2. 获取用户的微博_有 since_id 参数(作为连续爬取)

curl --location 'https://m.weibo.cn/api/container/getIndex?luicode=10000011&lfid=100103type%3D1%26q%3D%E5%8D%88%E5%90%8E&type=uid&value=1253846303&containerid=1076031253846303&since_id=5032119713661749' \
--header 'sec-ch-ua: "Chromium";v="124", "Google Chrome";v="124", "Not-A.Brand";v="99"' \
--header 'X-XSRF-TOKEN: d13f16' \
--header 'sec-ch-ua-mobile: ?0' \
--header 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36' \
--header 'Accept: application/json, text/plain, */*' \
--header 'MWeibo-Pwa: 1' \
--header 'Referer: https://m.weibo.cn/u/1253846303?t=&luicode=10000011&lfid=100103type%3D1%26q%3D%E5%8D%88%E5%90%8E' \
--header 'X-Requested-With: XMLHttpRequest' \
--header 'sec-ch-ua-platform: "Windows"' \

--header 'Cookie: WEIBOCN_FROM=1110106030; _T_WM=3251c71cea1ed12d7fc32617409daab6'

3. 根据关键词搜用户

curl --location 'https://m.weibo.cn/api/container/getIndex?containerid=100103type%3D3%26q%3D%E5%8D%88%E5%90%8E%E7%8B%82%E7%9D%A1%26t%3D&page_type=searchall' \
--header 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36' \
--header 'Accept: application/json, text/plain, */*' \
--header 'Cookie: WEIBOCN_FROM=1110106030; _T_WM=3251c71cea1ed12d7fc32617409daab6'

4. 获取用户信息(此接口会返回 containerid ,这个参数是获取微博的关键)

curl --location 'https://m.weibo.cn/api/container/getIndex?luicode=10000011&lfid=100103type%3D1%26q%3D%E5%8D%88%E5%90%8E&type=uid&value=1253846303' \
--header 'sec-ch-ua: "Chromium";v="124", "Google Chrome";v="124", "Not-A.Brand";v="99"' \
--header 'X-XSRF-TOKEN: d13f16' \
--header 'sec-ch-ua-mobile: ?0' \
--header 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36' \
--header 'Accept: application/json, text/plain, */*' \
--header 'MWeibo-Pwa: 1' \
--header 'Referer: https://m.weibo.cn/u/1253846303?t=&luicode=10000011&lfid=100103type%3D1%26q%3D%E5%8D%88%E5%90%8E' \
--header 'X-Requested-With: XMLHttpRequest' \
--header 'sec-ch-ua-platform: "Windows"' \
--header 'Cookie: WEIBOCN_FROM=1110106030; _T_WM=3251c71cea1ed12d7fc32617409daab6'

文章作者: Mark
版权声明: 本站所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 有限进步
爬虫实例 Python 爬虫
喜欢就支持一下吧
打赏
微信 微信
支付宝 支付宝