Instagram 抓取评论量

问题描述 投票:0回答:2

有谁知道是否有正确的方法来抓取 Instagram 个人资料?目标是自动收集特定用户帖子的评论量。

python web-scraping instagram-api
2个回答
2
投票

因此您需要使用正确的浏览器标头来访问此 API 端点,否则您将收到用户代理不匹配错误


axios.get("https://www.instagram.com/api/v1/feed/user/{username_of_account}/username/?count=12", {
  "headers": {... add all the headers that you get from the browser request},
  "method": "GET"
});

要收集您自己的浏览器标头,请转到网络选项卡并打开一些配置文件,您会发现很多网络请求。只需右键单击其中任何一个并复制为 Node fetch,您就会在那里找到标题。将这些内容复制粘贴到此请求中

作为响应,您将获得一个 json,其中包含一个名为 items 的数组。 迭代 items 数组,每个元素都会有一个名为

items[i].comment_count
的属性。我的意思是,items 数组的第 i 个元素。


0
投票

由于 Instagram 已禁止许多帐户,您可以通过 https://lamadava.readthedocs.io/en/latest/https://lamadava.com/p/2frU72UL

尝试以下方法

在这种情况下你需要考虑这样的方法

curl -X 'GET' \
  'https://api.lamadava.com/v2/user/medias?user_id=123123' \
  -H 'accept: application/json'

获得“comment_count”回复 -

"comment_count": 7

或使用 python 库

from lamadava import Client, AsyncClient

cl = Client(token="<your-token-here>")

res = cl.user_medis('123123')

您将通过链接进行试用https://lamadava.com/p/2frU72UL因此您可以自行测试。

© www.soinside.com 2019 - 2024. All rights reserved.