+
51
-

python selenium如何抓取下载整个网站html页面及js css图片?

python selenium如何抓取下载整个网站html页面及js css图片?


网友回复

+
0
-

可以调用的网页ctrl+s另存为

import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.expected_conditions import visibility_of_element_located
from selenium.webdriver.support.ui import WebDriverWait
import pyautogui
URL = 'http://baidu.com'
SEQUENCE = '唯一文件名,自己修改'
# 用selenium打开网页
# (首先要下载 Chrome webdriver, 或 firefox webdriver)
driver = webdriver.Chrome()
driver.get(URL)

# 等待结果加载
WebDriverWait(driver, 60).until(visibility_of_element_located((By.ID, 'grView')))
# 打开"另存为"来保存html和资源文件
pyautogui.hotkey('ctrl', 's')
time.sleep(1)
pyautogui.typewrite(SEQUENCE + '.html')
pyautogui.hotkey('enter')


by ppzhuzhu
我知道答案,我要回答