Skip to content

Instantly share code, notes, and snippets.

@agaerig
Created October 23, 2019 03:36
Show Gist options
  • Save agaerig/342007cb0964279ed067a785752a9160 to your computer and use it in GitHub Desktop.
Save agaerig/342007cb0964279ed067a785752a9160 to your computer and use it in GitHub Desktop.
import urllib2
import urllib
import json
api = 'https://api.redef.co/v1/articles/media?published_at=2019-10-22T15%3A35%3A09.540Z&half_card=true'
token = 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJlbWFpbCI6InRlc3RAdGVzdC5jb20iLCJoYXNoZWRfcGFzc3dvcmQiOiI4MWZjOGM3NDdhYzExYzRjOWQ0ZTE4N2ViMzg5ZTkyY2ZhNjQyNGVjIiwic2FsdCI6IjExNjEzNDM3ODgwMzciLCJfaWQiOiI1MzMxZWQwODQxYWIwMzU5MDUxOTU4ZGEiLCJfX3YiOjAsInJvbGVzIjpbXSwidHdpdHRlciI6eyJwaG90b3MiOltdfSwiY29udGFjdHMiOltdLCJjaGFubmVscyI6W119.YqXt4KqjL8LXRE5-7ZBGRTBonxAHLfmtimVjIT8bEt0'
headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36',
'Accept': 'application/json, text/javascript, */*; q=0.01',
'Sec-Fetch-Mode': 'cors',
'Referer': 'https://redef.com/channel/media/feed',
'Origin': 'https://redef.com',
'Authorization': token}
req = urllib2.Request(api, headers=headers)
try:
page = urllib2.urlopen(req)
resp = json.loads(page.read())
except urllib2.URLError as e:
print e
for story in resp:
if story['authors']:
print story['authors']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment