【发布时间】:2022-01-10 21:44:21
【问题描述】:
我正在尝试在 PYTHON 中制作一个应用程序,以 JSON 格式获取有关某人 instagram 页面的信息,然后以 JSON 格式将其返回到我的程序。
我收到此错误:simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0) 我搜索了帮助,但找不到任何东西。
有人可以帮助我并编辑我的代码以修复此错误吗?
我相信,当我运行我的代码时,我的程序会被提示到“instagram 登录页面”。因为你不能在没有登录的情况下访问 instagram API。
有什么方法可以让我的 requests.get() 登录到 instagram 并获取某人的 instagram 页面的 JSON?
请让我的代码正常工作。我正在尝试从用户的 Instagram 页面以 JSON() 格式获取信息。例如 = 'https://www.instagram.com/{USERNAME}/?__a=1'。
错误:
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)
我在 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'])
请有人帮助我,请有人编辑我的代码以使其工作。
PICTURE OF ALL THE JSON/TEXT I NEED INTO MY PROGRAM AS A VARIABLE
【问题讨论】:
标签: python json python-3.x instagram instagram-api