Reputation: 69
Good evening,
I want to scrape the testid. What I tried and which isn't working. What am I doing wrong?
Json = json.loads(info.content)
aba = Json['checkout']['line_items'].get("testid")
infocontent =
{
"checkout":{
"completed_at":null,
"created_at":"2020-02-27T17:43:50+01:00",
"line_items":[
{
"id":"538af6bda25ea2ba30811ca527631cc6",
"key":"538af6bda25ea2ba30811ca527631cc6",
"auth":4462126596176,
"testid":31830643277904,
}]
}
Upvotes: 1
Views: 82
Reputation:
The value of line_items
is a list of objects, albeit there is only one object in the list. You need to get the first item in the list before you can use get
on it.
aba = Json['checkout']['line_items'][0].get("testid")
Upvotes: 1