Gustavo Molina
Gustavo Molina

Reputation: 85

WebScraping issues in python using Selenium

I'm trying to scrape data from this website called Anhembi

But when I try all the options from selenium to find elements, I get nothing. Anyone know why this happens?

I've already tried:

driver.find_element_by_xpath('//*[@class="agenda_result_laco_box"]') 

And made a for-loop through that to click in every single one and get the info I need which consists of the day, website and name of the events. How can I do that?

Upvotes: 0

Views: 60

Answers (1)

cruisepandey
cruisepandey

Reputation: 29362

Clearly, there is an iframe involved , you need to switch the focus of your web driver in order to interact with elements which are in iframe/frameset/frame.

You can try with this code :

driver.get("http://www.anhembi.com.br/agenda/") 

driver.switch_to.frame(driver.find_element_by_css_selector("iframe[src='http://intranet.spturis.com.br/intranet/modulos/booking/anhembisite_busca.php']"))
all_data = driver.find_elements_by_css_selector("div.agenda_result_laco_box")

print(len(all_data))

for data in all_data:
  print(data.text)

Upvotes: 1

Related Questions