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
17 print("Broytman get_url, Copyright (C) 2024 PhiloSoft Design")
19 if len(sys.argv) != 3:
20 sys.stderr.write("Usage: get_url.py URL output_file\n")
23 from robots import robot
24 robot = robot(sys.stdout.write)
27 output_fname = sys.argv[2]
29 bookmark = Bookmark(href=url, add_date=None)
30 bookmark.parent = None
32 error, redirect_code, redirect_to, headers, content = \
33 robot.get(bookmark, url, True)
39 print("Moved to: %s" % redirect_to)
42 with open(output_fname, 'wb') as outfile:
43 outfile.write(content)
48 if __name__ == '__main__':