Ich versuche alle Breiten und Längen von diesem json zu erhalten.TypeError: Listenindizes müssen Ganzzahlen oder Slices sein, nicht str - von json kommen
Code:
import urllib.parse
import requests
raw_json = 'http://live.ksmobile.net/live/getreplayvideos?userid='
print()
userid = 735890904669618176
#userid = input('UserID: ')
url = raw_json + urllib.parse.urlencode({'userid=': userid}) + '&page_size=1000'
print(url)
json_data = requests.get(url).json()
print()
for coordinates in json_data['data']['video_info']:
print(coordinates['lat'], coordinates['lnt'])
print()
Fehler:
/usr/bin/python3.6 /media/anon/3D0B8DD536C9574F/PythonProjects/getLocation/getCoordinates
http://live.ksmobile.net/live/getreplayvideos?userid=userid%3D=735890904669618176&page_size=1000
Traceback (most recent call last):
File "/media/anon/3D0B8DD536C9574F/PythonProjects/getLocation/getCoordinates", line 17, in <module>
for coordinates in json_data['data']['video_info']:
TypeError: list indices must be integers or slices, not str
Process finished with exit code 1
Wo finde ich falsch?
Im Voraus, danke für Ihre Hilfe und Zeit.
Ich poste gerade einige der json, um zu zeigen, wie es aussieht. Die json sieht wie folgt aus:
{
"status": "200",
"msg": "",
"data": {
"time": "1499275646",
"video_info": [
{
"vid": "14992026438883533757",
"watchnumber": "38",
"topicid": "0",
"topic": "",
"vtime": "1499202678",
"title": "happy 4th of july",
"userid": "735890904669618176",
"online": "0",
"addr": "",
"isaddr": "2",
"lnt": "-80.1282576",
"lat": "26.2810628",
"area": "A_US",
"countryCode": "US",
"chatSystem": "1",
},
Voll json: https://pastebin.com/qJywTqa1
'json_data' muss eine Liste von dicts sein. Also muss das erste '[]' Argument ein Slice oder eine Ganzzahl sein ... –
... oder es ist ein Diktat, aber seine Komponenten sind es nicht. Ich glaube, das ist der Fall. –
Ohne einige Informationen zu Ihren Daten ist es schwer zu sagen. Bitte posten Sie Ihre JSON-Daten hier. –