Basic help for sub-lib interactive use
parent
2fe3e0b8ee
commit
4ccc0dafcd
|
@ -655,5 +655,8 @@ class MySQLCacheHandler(BaseCache):
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
req = adv_get(sys.argv[1] if len(sys.argv) > 1 else 'https://morss.it')
|
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']))
|
print(req['data'].decode(req['encoding']))
|
||||||
|
|
|
@ -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')
|
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'])
|
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:
|
for item in feed.items:
|
||||||
print(item.title, item.link)
|
print(item.title, item.link)
|
||||||
|
|
|
@ -351,5 +351,8 @@ if __name__ == '__main__':
|
||||||
req = crawler.adv_get(sys.argv[1] if len(sys.argv) > 1 else 'https://morss.it')
|
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')
|
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)
|
print(article)
|
||||||
|
|
Loading…
Reference in New Issue