Search code examples
pythonweb-scrapinginstagram-api

How to resolve "json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes" in headers for instascrape?


I am new to instascrape library of python. I am trying to write a code to download a given reel.

from instascrape import Reel

SESSIONID = '2248906093%3A3FYd2HBRoyhW48%3A15%3AAYcqicDd5En5SuwzN0AUc5U29PJVp7V0zsQLQ80fxQ'

headers = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.74 Safari/537.36 Edg/79.0.309.43",
"cookie":f'sessionid={SESSIONID};'
}

insta_reel = Reel(
    'https://www.instagram.com/reel/BiFaD8loJlJ/')

insta_reel.scrape(headers=headers)

insta_reel.download(fp=f".\\Pictures\\reel.mp4")

print('Downloaded Successfully.')

I am getting error:

 File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1776.0_x64__qbz5n2kfra8p0\lib\json\decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)

Can you please guide me?


Solution

  • The bug is described at instascrape Github repo one month ago, and the author hasn't answered yet.

    Details: https://github.com/chris-greening/instascrape/issues/164

    P.S. IMO, the repo seems forsaken, the last commit is almost one year old. Perhaps you should fix the bug by yourself, or look for another tool.