mercredi 15 juin 2016

How can these javascript links be traversed with Selenium or BeautifulSoup?


I’ve opted for Selenium since the links’ hrefs are generated dynamically, although some method via bs4 would be preferred.

I'm using PhantomJS but have tried Firefox as well

When attempting to click a link, nothing happens.

For instance,

url = 'http://www.achema.de/de/ausstellung/aussteller-und-produkte.html'

driver.get(url)

resultsBox = driver.find_element_by_css_selector('div[id="ix_result"]')

for tr in resultsBox.find_elements_by_tag_name('tr'):
    link = tr.find_element_by_tag_name('a')
    link.click()

    # I've also tried:
    # ActionChains(driver).move_to_element(link).click(link).perform()

Aucun commentaire:

Enregistrer un commentaire