diff options
author | Hugo Hörnquist <hugo@hornquist.se> | 2018-11-09 23:26:42 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@hornquist.se> | 2018-11-09 23:26:42 +0100 |
commit | ebb16d1dabedfdc3fc392b8c36f46a486ee3549f (patch) | |
tree | ded1669ddaeb7416526bfdd0659e5f1d15458e62 /texttv.py | |
download | texttv-ebb16d1dabedfdc3fc392b8c36f46a486ee3549f.tar.gz texttv-ebb16d1dabedfdc3fc392b8c36f46a486ee3549f.tar.xz |
Initial commit.t
Diffstat (limited to 'texttv.py')
-rwxr-xr-x | texttv.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/texttv.py b/texttv.py new file mode 100755 index 0000000..a6cf2b1 --- /dev/null +++ b/texttv.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python2 + +from httplib2 import Http +from urllib import urlencode +import json +import re +import sys + +def cleanhtml(raw_html): + cleanr = re.compile('<.*?>') + cleantext = re.sub(cleanr, '', raw_html) + return cleantext + +if len(sys.argv) > 1: + page = sys.argv[1] +else: + page = '100' + +http = Http() +url = 'http://api.texttv.nu/api/get/' + page + '?app=python' +headers = {'Accept': 'application/json', 'Accept-Language': 'en-US,en'} +response, content = http.request(url, 'GET', headers=headers) +data = json.loads(content) +print cleanhtml(data[0]['content'][0]) |