My objective is to write a script that finds a random post from a set instagram profile, and then it'll output the post link.
Here's what I first tried.
import random
import instaloader
L = instaloader.Instaloader()
profile = instaloader.Profile.from_username(L.context, 'leomessi')
posts = profile.get_posts()
random_post = random.choice(list(posts))
print(random_post.url)
then I was greeted with this.
JSON Query to api/v1/users/web_profile_info/?username=username: 404 Not Found [retrying; skip with ^C]
JSON Query to api/v1/users/web_profile_info/?username=username: 404 Not Found [retrying; skip with ^C]
JSON Query to web/search/topsearch/: HTTP error code 401. [retrying; skip with ^C]
JSON Query to web/search/topsearch/: HTTP error code 401. [retrying; skip with ^C]
Traceback (most recent call last):
File "C:\Users\abcd\AppData\Local\Programs\Python\Python310\lib\site-packages\instaloader\instaloadercontext.py", line 348, 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 "C:\Users\abcd\AppData\Local\Programs\Python\Python310\lib\site-packages\instaloader\instaloadercontext.py", line 348, 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 "C:\Users\abcd\AppData\Local\Programs\Python\Python310\lib\site-packages\instaloader\instaloadercontext.py", line 348, in get_json
raise QueryReturnedNotFoundException("404 Not Found")
instaloader.exceptions.QueryReturnedNotFoundException: 404 Not Found
I've tried the login feature of instaloader, but it keeps flagging it as suspicious. I tried the firefox generated session file workaround, which didn't work.