Python TypeError: string indices must be integers error

107 Views Asked by At

I am trying to use ycombinators api in order to get the top news articles. However I keep on getting this error TypeError: string indices must be integers

Heres my code

articles_list = []
y= requests.get("https://hacker-news.firebaseio.com/v0/newstories.json")
y = y.json()
print(y)
print("https://hacker-news.firebaseio.com/v0/item/" + number +".json" +"?print=pretty")
for number in y:
    req = requests.get("https://hacker-news.firebaseio.com/v0/item/" + str(number) +".json" +"?print=pretty")
    req = req.json()
    print(req)
    break
for thing in req["url"]:
    articles_list.append(thing["url"])

I can not understand whats wrong....

0

There are 0 best solutions below