simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0) while finding JSON in Instagram

Viewed 210

I am trying to make a app in PYTHON that gets information about someones instagram page in JSON, then returns it to my program in JSON format.

I am getting this error : simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0) I searched help, but could not find anything.

Can someone help me and edit my code to fix this error?

I believe that, when I run my code, my program gets prompted to 'instagram login page'. Because you can't access the instagram API without a login.

Is there any way you can get my requests.get() to login into instagram and get the JSON for someone's instagram page?

Please make my code work.. I am trying to get information out from a user's instagram page in JSON() format. e.g = 'https://www.instagram.com/{USERNAME}/?__a=1'.

ERROR:

Traceback (most recent call last):
  File "C:\Users\disco\PycharmProjects\IgOSINT\main.py", line 13, in <module>
    json_found_for_site = request_for_site.json()['graphql']['user']
  File "C:\Users\disco\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\models.py", line 910, in json
    return complexjson.loads(self.text, **kwargs)
  File "C:\Users\disco\AppData\Local\Programs\Python\Python39\lib\site-packages\simplejson\__init__.py", line 525, in loads
    return _default_decoder.decode(s)
  File "C:\Users\disco\AppData\Local\Programs\Python\Python39\lib\site-packages\simplejson\decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "C:\Users\disco\AppData\Local\Programs\Python\Python39\lib\site-packages\simplejson\decoder.py", line 400, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

MY CODE IN PYTHON:

import requests
from termcolor import colored

headers = {'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36'}

target = str(input(colored('[+] Enter Target Username: ', 'blue')))

request_for_site = requests.get('https://www.instagram.com/' + target + '/?__a=1', headers=headers)
print(request_for_site.text)

if request_for_site.status_code == 200:
    print(colored('[+++] TARGET FOUND !', 'green'))
    json_found_for_site = request_for_site.json()['graphql']['user']
    print(colored(
        '''
        [1] USERNAME    
        [2] FULL NAME
        [3] BIO
        [4] HIGHLIGHTS
        [5] PHONE NUMBER
        [6] IS ACCOUNT PRIVATE OR PUBLIC [recommended FIRST]
        [7] Profile Picture
        [8] Followers
        [9] Followed
        [10] ID
        [11] IS VERIFIED
        ''', 'red'
    ))
    tool_option = str(input(colored('[+] ENTER NUMBER OPTION TO FIND: ', 'blue')))
    if tool_option == '1':
        print(json_found_for_site['username'])
    elif tool_option == '2':
        print(json_found_for_site['full_name'])



Someone please help me, someone please edit my code to make it work.

PICTURE OF ALL THE JSON/TEXT I NEED INTO MY PROGRAM AS A VARIABLE

1 Answers
Related