summaryrefslogtreecommitdiff
path: root/textract
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2018-06-13 21:36:56 -0700
committerBen Sima <ben@bsima.me>2018-06-13 21:36:56 -0700
commit77c9a177b2b595d4ce25095b58e2388fe33cc97a (patch)
tree0853d5c92d67538760005b9c4635a90115bd7ba4 /textract
init
Diffstat (limited to 'textract')
-rwxr-xr-xtextract19
1 files changed, 19 insertions, 0 deletions
diff --git a/textract b/textract
new file mode 100755
index 0000000..996393f
--- /dev/null
+++ b/textract
@@ -0,0 +1,19 @@
+#!/usr/bin/env python3.5
+
+import argparse
+from readability import Document
+import requests
+import sys
+
+cli = argparse.ArgumentParser('read a url')
+cli.add_argument('url', type=str)
+
+if __name__ == '__main__':
+ try:
+ args = cli.parse_args()
+ resp = requests.get(args.url)
+ doc = Document(resp.text)
+ sys.stdout.write(doc.summary())
+ sys.exit(0)
+ except:
+ sys.exit(1)