Created
August 31, 2015 05:14
-
-
Save gslin/cdb90401a7a0e31eb8af to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import json | |
import sys | |
import urllib.parse | |
import urllib.request | |
if __name__ == '__main__': | |
email = 'darkkiller@gmail.com' | |
password = 'x' | |
r = urllib.request.urlopen( | |
'https://api.zite.com/api/account/login', | |
bytearray(urllib.parse.urlencode({'email': email, 'password': password}), 'utf-8'), | |
) | |
if 200 != r.status: | |
raise SystemExit('Login failed') | |
data = json.loads(str(r.read(), 'utf-8')) | |
token = data['accessToken'] | |
user_id = data['userId'] | |
param = urllib.parse.urlencode({ | |
'accessToken': token, | |
'appver': '2.0', | |
'deviceType': 'ipad', | |
'userId': user_id, | |
}) | |
r = urllib.request.urlopen( | |
'https://api.zite.com/api/v2/news/?%s' % (param) | |
) | |
if 200 != r.status: | |
raise SystemExit('News fetch failed') | |
body = json.loads(str(r.read(), 'utf-8')) | |
for doc in body['documents']: | |
print(doc['url']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment