instaloader: Error when downloading Hashtags: `Expecting value: line 1 column 1 (char 0)`

Describe the bug Hashtags not found when using session

To Reproduce Steps to reproduce the behavior:

$ instaloader -l rayamberg "#lisaandrewsartist"
Loaded session from /home/rsa/.config/instaloader/session-rayamberg.
Logged in as rayamberg.
JSON Query to explore/tags/lisaandrewsartist/: Expecting value: line 1 column 1 (char 0) [retrying; skip with ^C]
JSON Query to explore/tags/lisaandrewsartist/: Expecting value: line 1 column 1 (char 0) [retrying; skip with ^C]
Get hashtag #lisaandrewsartist: JSON Query to explore/tags/lisaandrewsartist/: Expecting value: line 1 column 1 (char 0)
Saved session to /home/rsa/.config/instaloader/session-rayamberg.

Errors or warnings occurred:
Get hashtag #lisaandrewsartist: JSON Query to explore/tags/lisaandrewsartist/: Expecting value: line 1 column 1 (char 0)

Expected behavior I expected to be able to download the posts for the given hashtag. Note that it works when I supply the password directly to instaloader:

$ instaloader -l rayamberg -p ****** "#lisaandrewsartist"
Session file does not exist yet - Logging in.
Logged in as rayamberg.
#lisaandrewsartist/2022-04-20_06-34-03_UTC_profile_pic.jpg 
Retrieving pictures with hashtag #lisaandrewsartist...
[  1] #lisaandrewsartist/2022-04-20_06-42-39_UTC.jpg [Meet the Artist Lisa Andrews …] json 
[  2] #lisaandrewsartist/2022-04-20_06-42-33_UTC.jpg [Meet the Artist Lisa Andrews …] json 
[  3] #lisaandrewsartist/2022-04-20_06-37-47_UTC.jpg [We love this painting of Swee…] json 
...
Saved session to /home/rsa/.config/instaloader/session-rayamberg.
$

Error messages and tracebacks See traceback above

Instaloader version 4.9.1

Additional context It’s happening for all hashtags I am testing. They all return posts when I don’t use a session and return the JSON Query error when I do use a session. I can download other things when I use a session, e.g. instaloader -l rayamberg someprofile works. I’m writing a python script and getting the same unexpected behavior when I use load_session_from_file("rayamberg") and expected behavior when I use login("rayamberg", "mypass"). I used the Firefox script on the troubleshooting page to try to resolve the issue, and although it appeared to successfully import the session, the issue persists.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 22 (1 by maintainers)

Most upvoted comments

Thanks for the bug report. I was able to reproduce the error. It actually appears both when using an existing session and when using a fresh login.

Same, im getting the html in my resp and it crashes. Any clues or any details on fixes?

I’m having the same issue, with a code that used to function well until about a month ago. I investigated a bit, I hope this helps: It seems it comes from the get_json method of the InstaLoaderContext class, so I compared the behaviour of this method when calling Profile.from_username vs. when calling Hashtag.from_name. The result I see differs on line 325 in instaloadercontext.py, that is: resp = sess.get('https://{0}/{1}'.format(host, path), params=params, allow_redirects=False)

In the first case when calling Profile.from_username in my main code, the line mentioned above yields a requests.models.Response object whose content is well formatted, so that calling resp_json = resp.json() on line 370 of the same file works fine. When calling Hashtag.from_name, the same request result returns a Response object whose content is the html code of the page, which cannot be processed correctly and crashes when calling resp_json = resp.json() on line 370, causing the error Expecting value: line 1 column 1 (char 0).

So, I would suspect Instagram changed the format of the result returned when calling the API for hashtags, do you have any clue on that?