Reputation: 753
When I right-click on a page in my browser, I can "Save Page As", saving the entire webpage including images, css, and js. I've seen questions answered on downloading a page's content, but this only retrieves the HTML. Is there a solution with urllib2, requests, or any other library, to downloading the complete page?
Upvotes: 11
Views: 3075
Reputation: 1928
You can use pyautogui
coupled with selenium
to achieve this.
import time
from selenium import webdriver
import pyautogui
URL = 'https://example.com'
# open page with selenium
# (first need to download Chrome webdriver, or a firefox webdriver, etc)
driver = webdriver.Chrome()
driver.get(URL)
# open 'Save as...' to save html and assets
pyautogui.hotkey('ctrl', 's')
time.sleep(1)
pyautogui.typewrite('your_filename' + '.html')
pyautogui.hotkey('enter')
Upvotes: 4