Python Forum
Thread Rating:
  • 2 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Reading json from webpage
#1
For starters I'm just trying to learn how to pull some json data off a siriusxm page. (( Here's a link, but the time stamped page doesn't last very long. siriusxm page

My code looks like it grabs all the data fine, but I need assistance on how to pull specific data from the json.
import urllib3
import json


http = urllib3.PoolManager()

r = http.request('GET', 'https://www.siriusxm.com/metadata/pdt/en-us/json/channels/firstwave/timestamp/01-10-18:00:00')

print(json.loads(r.data.decode('utf-8'))['channelMetadataResponse'])
for example, the json.loads(r.data.decode('utf-8'))['channelMetadataResponse'] has the data just fine, but changing the syntax to
json.loads(r.data.decode('utf-8'))['artists':'name'] gives a slicing error.

Direction would be grateful. Thank you so much!

In case the link dies or is blank. here is a sample from their page. you may need copy paste into http://jsonviewer.stack.hu to read it better.

{"channelMetadataResponse":{"messages":{"code":100,"message":"Successful request"},"status":1,"metaData":{"channelId":"firstwave","channelName":"1st Wave","channelNumber":33,"currentEvent":{"artists":{"id":"8_l","name":"Talking Heads"},"baseUrl":"http:\/\/albumart.siriusxm.com\/albumart\/","keyIndex":"null","siriusXMId":568746322,"song":{"album":{"name":"Little Creatures"},"composer":"","creativeArts":[{"encrypted":false,"size":"THUMBNAIL","type":"IMAGE","url":"1730\/NDCA-000017418-003_t.jpg"},{"encrypted":false,"size":"SMALL","type":"IMAGE","url":"1730\/NDCA-000017418-003_s.jpg"},{"encrypted":false,"size":"MEDIUM","type":"IMAGE","url":"1730\/NDCA-000017418-003_m.jpg"},{"encrypted":false,"size":"LARGE","type":"IMAGE","url":""},{"encrypted":false,"type":"BIO","url":""},{"encrypted":false,"type":"REVIEWS","url":""},{"encrypted":true,"size":"THUMBNAIL","type":"IMAGE","url":"1730\/NDCA-000017418-003_t.jpg"},{"encrypted":true,"size":"SMALL","type":"IMAGE","url":"1730\/NDCA-000017418-003_s.jpg"},{"encrypted":true,"size":"MEDIUM","type":"IMAGE","url":"1730\/NDCA-000017418-003_m.jpg"},{"encrypted":true,"size":"LARGE","type":"IMAGE","url":""},{"encrypted":true,"type":"BIO","url":""},{"encrypted":true,"type":"REVIEWS","url":""}],"id":"$O4GA","name":"Stay Up Late"},"startTime":"2019-01-10T17:46:51Z"},"dateTime":"2019-01-10T17:49:52.311Z","version":1.1}}}
Reply


Messages In This Thread
Reading json from webpage - by jmair - Jan-10-2019, 06:15 PM
RE: Reading json from webpage - by stullis - Jan-10-2019, 06:40 PM
RE: Reading json from webpage - by jmair - Jan-10-2019, 08:52 PM
RE: Reading json from webpage - by buran - Jan-10-2019, 09:04 PM
RE: Reading json from webpage - by jmair - Jan-10-2019, 09:14 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  TypeRoor reading json GreenLynx 3 800 May-16-2023, 01:47 PM
Last Post: buran
  Reading Data from JSON tpolim008 2 1,032 Sep-27-2022, 06:34 PM
Last Post: Larz60+
  Initializing, reading and updating a large JSON file medatib531 0 1,724 Mar-10-2022, 07:58 PM
Last Post: medatib531
  Help with reading json file hhchenfx 5 4,407 Jul-07-2021, 01:58 PM
Last Post: hhchenfx
  reading json file DrBrownStats 1 1,791 Nov-25-2020, 09:00 AM
Last Post: Larz60+
  Reading a json file ebolisa 2 2,113 Mar-15-2020, 09:24 AM
Last Post: ebolisa
  Reading json behind a login page ebolisa 3 2,380 May-26-2019, 05:15 PM
Last Post: heiner55
  Reading JSON - error jmair 2 2,204 May-22-2019, 07:25 PM
Last Post: jmair
  [split] Reading json from webpage rajesh1997 1 2,162 Feb-05-2019, 12:07 PM
Last Post: buran
  Reading complex JSON dictionaries Gromis 5 3,749 Jul-08-2018, 10:26 PM
Last Post: Gromis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020