1 #! /usr/bin/env python3
2 """Get one file from an URL
4 This file is a part of Bookmarks database and Internet robot.
7 __author__ = "Oleg Broytman <phd@phdru.name>"
8 __copyright__ = "Copyright (C) 2024 PhiloSoft Design"
9 __license__ = "GNU GPL"
13 from bkmk_objects import Bookmark
14 from Writers.bkmk_wflad import strftime
18 print("Broytman get_url, Copyright (C) 2024 PhiloSoft Design")
20 if len(sys.argv) != 3:
21 sys.stderr.write("Usage: get_url.py URL output_file\n")
24 from robots import robot
25 robot = robot(sys.stdout.write)
28 output_fname = sys.argv[2]
30 bookmark = Bookmark(href=url, add_date=None)
31 bookmark.parent = None
33 error, redirect_code, redirect_to, headers, content = \
34 robot.get(bookmark, url, True)
40 print("Moved to: %s" % redirect_to)
54 getattr(bookmark, 'real_title', None)
55 or getattr(bookmark, 'title', None),
57 strftime(bookmark.last_modified),
58 getattr(bookmark, 'moved', None),
59 getattr(bookmark, 'size', None),
60 getattr(bookmark, 'md5', None),
61 bookmark.icon_href, bookmark.icon, bookmark.charset,
65 with open(output_fname, 'wb') as outfile:
66 outfile.write(content)
71 if __name__ == '__main__':