[英]Is there a way to get a HTML as Browser will render it, CSS and JS
我正在尋找一種呈現HTML的方式,並獲得整個文件源,例如在瀏覽器(例如firefox)之后呈現它的情況……我正在使用一些編號,只是外觀,例如如CSS ::before
或javascript突出顯示代碼塊,或呈現Mathjax。
我的問題是,是否有辦法進行“服務器渲染”? 如果可以,怎么辦?
使用諸如selenium之類的網絡驅動程序,只需打開要渲染的文件或URI,並在渲染后獲取頁面的源即可。
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument("--headless")
driver = webdriver.Chrome(chrome_options=chrome_options)
driver.get(URI)
source = driver.page_source
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.