【发布时间】:2018-08-09 23:12:48
【问题描述】:
我正在尝试使用 python 3 和 webdriver 提取 javascript 呈现的表。
我的代码如下:
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
# Create a new instance of the Firefox driver
driver = webdriver.Firefox()
driver.get("http://esploracolfis.sns.it/EsploraCoLFIS/#!0:t=L&l=1;1:r=T")
driver.refresh()
# Wait for the dynamically loaded elements to show up
WebDriverWait(driver, 10).until(
EC.visibility_of_element_located((By.TAG_NAME, "table")))
# And grab the page HTML source
html = driver.page_source
driver.quit()
print(html)
现在,当我打印正文时,我的打印中不存在 javascript 呈现的内容。 如何提取我想要的表格(表格的整个 html 代码)?
非常感谢
【问题讨论】:
标签: javascript python selenium web-scraping webdriver