rajatomar788 / pywebcopy

Locally saves webpages to your hard disk with images, css, js & links as is.
https://rajatomar788.github.io/pywebcopy/
Other
520 stars 105 forks source link

Relative Path Support #113

Open BradKML opened 1 year ago

BradKML commented 1 year ago

Because of issues like the following https://github.com/rajatomar788/pywebcopy/issues/56 It would be useful to have support for relative paths, especially when the code is used in Jupyter Notebooks for maximum compatibility.

Right now I kind of hack it with this solution:

import os # borrowed from https://stackoverflow.com/a/14125914
relative_path = r'book_test'
current_directory = os.getcwd()
final_directory = os.path.join(current_directory, relative_path)
if not os.path.exists(final_directory): os.makedirs(final_directory)

website = 'https://www.nateliason.com/notes' # or whatever target
from pywebcopy import save_website
save_website(website, project_folder=final_directory)

Some notes: can only get a single page instead of the whole website.