aboutsummaryrefslogtreecommitdiff
path: root/texttv.py
diff options
context:
space:
mode:
Diffstat (limited to 'texttv.py')
-rwxr-xr-xtexttv.py24
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])