Using selenium with python to extract javascript-generated HTML? Firebug?

浪尽此生 提交于 2019-12-01 12:45:08

问题


Python noobie here.

What I have is a data harvesting problem. I'm on this website, and when I inspect the element that I want with Firebug, it shows the source containing the information I need. However the regular source code (without Firebug) doesn't give me this info. This means I also can't get the data with the normal selenium HTML grabbing, either.

I'm wondering if there is a way that selenium can grab this data like Firebug does -- I'm guessing this is HTML that is generated after the page loads with javascript or jquery.

Here is a picture: http://i.imgur.com/CXLOHYx.png

You can see that the info I want is 'greyed out', unlike most of the other HTML there. Maybe that is a good clue as to what kind of data that really is.


回答1:


Try to use the following code and see if it works.

import selenium.webdriver.support.ui

element = WebDriverWait(driver, 10).until(
        lambda driver : driver.find_element_by_xpath("fImageMap > area:nth-child(2)")
)


来源:https://stackoverflow.com/questions/15623388/using-selenium-with-python-to-extract-javascript-generated-html-firebug

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!