From 4ccc0dafcdd6ba01a992612f555e7422a4f1ae7f Mon Sep 17 00:00:00 2001 From: pictuga Date: Tue, 26 May 2020 19:34:20 +0200 Subject: [PATCH] Basic help for sub-lib interactive use --- morss/crawler.py | 5 ++++- morss/feeds.py | 5 ++++- morss/readabilite.py | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/morss/crawler.py b/morss/crawler.py index 2b7c383..101563e 100644 --- a/morss/crawler.py +++ b/morss/crawler.py @@ -655,5 +655,8 @@ class MySQLCacheHandler(BaseCache): if __name__ == '__main__': req = adv_get(sys.argv[1] if len(sys.argv) > 1 else 'https://morss.it') - if not sys.flags.interactive: + if sys.flags.interactive: + print('>>> Interactive shell: try using `req`') + + else: print(req['data'].decode(req['encoding'])) diff --git a/morss/feeds.py b/morss/feeds.py index 65ada53..afef75b 100644 --- a/morss/feeds.py +++ b/morss/feeds.py @@ -780,6 +780,9 @@ if __name__ == '__main__': req = crawler.adv_get(sys.argv[1] if len(sys.argv) > 1 else 'https://www.nytimes.com/', follow='rss') feed = parse(req['data'], url=req['url'], encoding=req['encoding']) - if not sys.flags.interactive: + if sys.flags.interactive: + print('>>> Interactive shell: try using `feed`') + + else: for item in feed.items: print(item.title, item.link) diff --git a/morss/readabilite.py b/morss/readabilite.py index 0a945e0..167370b 100644 --- a/morss/readabilite.py +++ b/morss/readabilite.py @@ -351,5 +351,8 @@ if __name__ == '__main__': req = crawler.adv_get(sys.argv[1] if len(sys.argv) > 1 else 'https://morss.it') article = get_article(req['data'], url=req['url'], encoding_in=req['encoding'], encoding_out='unicode') - if not sys.flags.interactive: + if sys.flags.interactive: + print('>>> Interactive shell: try using `article`') + + else: print(article)