使用python解析从selenium到beautiful soup的数据

2024-06-09 05:28:45 发布

您现在位置:Python中文网/ 问答频道 /正文

我知道错误了

FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do 
you need to install a parser library?

我进口的是。。。在

^{pr2}$

我的代码是。。。在

在(driver.page_源使用print语句自行正确打印,但不会解析为beautifulsoup)

from selenium import webdriver
driver = webdriver.Firefox()
driver.get(url2)
driver.set_window_position(0, 0)
driver.set_window_size(100000, 200000)
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
time.sleep(5) # wait to load
html = driver.page_source
driver.quit()
import lxml
soup = BeautifulSoup(html, 'lxml')
print soup

它不喜欢的是。。。在

    FeatureNotFound                           Traceback (most recent call last)
<ipython-input-17-62919c26be91> in <module>()
     73 driver.quit()
     74 from lxml import etree
---> 75 soup = BeautifulSoup(html, 'lxml'

Tags: tofromimportyouhtmldriverpagewindow