Make it possible to call sub-libs in non interactive mode

Run `python -m morss.feeds http://lemonde.fr` and so on
master
pictuga 2020-04-27 18:00:14 +02:00
parent 2806c64326
commit 818cdaaa9b
3 changed files with 11 additions and 1 deletions

View File

@ -576,4 +576,7 @@ class MySQLCacheHandler(BaseCache):
if __name__ == '__main__':
data = get(sys.argv[1] if len(sys.argv) > 1 else 'https://morss.it')
data, con, contenttype, encoding = adv_get(sys.argv[1] if len(sys.argv) > 1 else 'https://morss.it')
if not sys.flags.interactive:
print(data.decode(encoding))

View File

@ -761,3 +761,7 @@ if __name__ == '__main__':
data, con, contenttype, encoding = crawler.adv_get(sys.argv[1] if len(sys.argv) > 1 else 'https://www.nytimes.com/', follow='rss')
feed = parse(data, url=con.geturl(), mimetype=contenttype, encoding=encoding)
if not sys.flags.interactive:
for item in feed.items:
print(item.title, item.link)

View File

@ -350,3 +350,6 @@ if __name__ == '__main__':
data, con, contenttype, encoding = crawler.adv_get(sys.argv[1] if len(sys.argv) > 1 else 'https://morss.it')
article = get_article(data, url=con.geturl(), encoding=encoding)
if not sys.flags.interactive:
print(article.decode(encoding))