我不断收到错误,当我尝试使用 instaloader 从特定主题标签中抓取帖子时,我收到错误:JSON Query to explore/tags/hashtag/: 404 Not Found 这是我的脚本:
from itertools import islice
import instaloader
username = ''
password = ''
hashtag = 'food'
L = instaloader.Instaloader()
L.login(username, password)
posts = L.get_hashtag_posts(hashtag)
for post in posts:
print(post.url)
这是完整的错误消息:
JSON Query to explore/tags/hashtag/: 404 Not Found [retrying; skip with ^C]
JSON Query to explore/tags/hashtag/: 404 Not Found [retrying; skip with ^C]
Traceback (most recent call last):
File "/Users/marcus/opt/anaconda3/lib/python3.9/site-packages/instaloader/instaloadercontext.py", line 405, in get_json
raise QueryReturnedNotFoundException("404 Not Found")
instaloader.exceptions.QueryReturnedNotFoundException: 404 Not Found
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/marcus/opt/anaconda3/lib/python3.9/site-packages/instaloader/instaloadercontext.py", line 405, in get_json
raise QueryReturnedNotFoundException("404 Not Found")
instaloader.exceptions.QueryReturnedNotFoundException: 404 Not Found
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/marcus/opt/anaconda3/lib/python3.9/site-packages/instaloader/instaloadercontext.py", line 405, in get_json
raise QueryReturnedNotFoundException("404 Not Found")
instaloader.exceptions.QueryReturnedNotFoundException: 404 Not Found
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/marcus/Documents/python/instascraper/main.py", line 12, in <module>
posts = L.get_hashtag_posts('hashtag')
File "/Users/marcus/opt/anaconda3/lib/python3.9/site-packages/instaloader/instaloader.py", line 1204, in get_hashtag_posts
return Hashtag.from_name(self.context, hashtag).get_posts_resumable()
File "/Users/marcus/opt/anaconda3/lib/python3.9/site-packages/instaloader/structures.py", line 1662, in from_name
hashtag._obtain_metadata()
File "/Users/marcus/opt/anaconda3/lib/python3.9/site-packages/instaloader/structures.py", line 1676, in _obtain_metadata
self._node = self._query({"__a": 1, "__d": "dis"})
File "/Users/marcus/opt/anaconda3/lib/python3.9/site-packages/instaloader/structures.py", line 1671, in _query
json_response = self._context.get_json("explore/tags/{0}/".format(self.name), params)
File "/Users/marcus/opt/anaconda3/lib/python3.9/site-packages/instaloader/instaloadercontext.py", line 435, in get_json
return self.get_json(path=path, params=params, host=host, session=sess, _attempt=_attempt + 1,
File "/Users/marcus/opt/anaconda3/lib/python3.9/site-packages/instaloader/instaloadercontext.py", line 435, in get_json
return self.get_json(path=path, params=params, host=host, session=sess, _attempt=_attempt + 1,
File "/Users/marcus/opt/anaconda3/lib/python3.9/site-packages/instaloader/instaloadercontext.py", line 423, in get_json
raise QueryReturnedNotFoundException(error_string) from err
instaloader.exceptions.QueryReturnedNotFoundException: JSON Query to explore/tags/hashtag/: 404 Not Found
如有任何帮助,我们将不胜感激。
Instagram 似乎暂时屏蔽了您的 IP 地址,因为
unusual activity
您需要更改地址或使用优质 VPN。
您再尝试一下是否是IP被封?