【问题标题】:How to parse the page once the onclick element is executed执行 onclick 元素后如何解析页面
【发布时间】:2017-07-01 03:11:26
【问题描述】:

我正在使用 selenium webdriver 来点击 javascript onclick 元素。单击后,我想使用 BeautifulSoup 解析单击元素的内容。这是我点击元素的代码。

from selenium import webdriver
driver = webdriver.Chrome()
url='https://www.mobikwik.com/'
driver.get(url)
el = driver.find_element_by_css_selector(".check-plans.ng-scope")
el.click()

现在我想进一步解析我可以看到的计划。我该怎么做?

【问题讨论】:

  • 所以,如果你想用BeautifulSoup解析内容,那么导入它并适当使用。有什么问题?你能描述一下你遇到的具体问题吗?
  • 选择要获取的元素。 click() 之后

标签: python-3.x selenium-webdriver beautifulsoup selenium-chromedriver


【解决方案1】:

如果您将驱动程序从驱动程序加载的页面的 html 输入到漂亮的汤中,那么您可以将其作为已解析的页面进行导航。使用soup.find() 再次找到您要查找的元素,然后您可以相应地对其进行导航。

soup = BeautifulSoup(el.text, 'html5lib')

看here for reference to a similar question。

【讨论】:

    猜你喜欢
    • 2012-12-28
    • 1970-01-01
    • 2017-09-22
    • 1970-01-01
    • 1970-01-01
    • 2012-02-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多