use file with links as arguments
This commit is contained in:
parent
514b39d287
commit
5c9d04cf3d
36
nevernote.py
36
nevernote.py
@ -126,6 +126,22 @@ def complete_url(url, base_url):
|
|||||||
return url
|
return url
|
||||||
|
|
||||||
|
|
||||||
|
def process_url(url):
|
||||||
|
print('Processing URL: %s' % url)
|
||||||
|
try:
|
||||||
|
url_duplicate(url)
|
||||||
|
except UrlDuplicateError as e:
|
||||||
|
print(e)
|
||||||
|
return
|
||||||
|
page = get_text(url)
|
||||||
|
parser = TitleParser(strict=False)
|
||||||
|
parser.feed(page)
|
||||||
|
|
||||||
|
page = embed_pictures(page, parser.images, base_url=url)
|
||||||
|
page = embed_css(page, parser.css, base_url=url)
|
||||||
|
write_file(page, parser.title, comment=url)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
description='Nevernote - download pages locally.')
|
description='Nevernote - download pages locally.')
|
||||||
@ -133,19 +149,13 @@ def main():
|
|||||||
help='URL of page to download')
|
help='URL of page to download')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
for url in args.urls:
|
for arg in args.urls:
|
||||||
try:
|
if os.path.isfile(arg):
|
||||||
url_duplicate(url)
|
print('Found file %s' % arg)
|
||||||
except UrlDuplicateError as e:
|
for url in (line.strip() for line in open(arg)):
|
||||||
print(e)
|
process_url(url)
|
||||||
continue
|
else:
|
||||||
page = get_text(url)
|
process_url(arg)
|
||||||
parser = TitleParser(strict=False)
|
|
||||||
parser.feed(page)
|
|
||||||
|
|
||||||
page = embed_pictures(page, parser.images, base_url=url)
|
|
||||||
page = embed_css(page, parser.css, base_url=url)
|
|
||||||
write_file(page, parser.title, comment=url)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user