Basic help for sub-lib interactive use

master
pictuga 2020-05-26 19:34:20 +02:00
parent 2fe3e0b8ee
commit 4ccc0dafcd
3 changed files with 12 additions and 3 deletions

View File

@ -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']))

View File

@ -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)

View File

@ -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)