问题
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