I am trying to scrape this website which would display utility bills information once details have been inserted. The website requires me to insert some info as well as clicking on some options.
I have been reading about Selenium and how to implement the “fill the details” and “click the button” option. However, I found hard to understand what “code” to insert from the html of the website to make the python code work.
I am basically stuck at the very beginning:
url = 'https://www.facile.it/energia-dual-fuel/preventivo.html'
# Your information
name = 'Mario Rossi' # random name
email = '[email protected]' # random email
phone = '3333333333' # random number
zip_code = '20019' # some random postcode for Milan
# Initialize the Chrome WebDriver
driver = webdriver.Chrome()
# Open the website
driver.get(url)
So far so good, from here onwards I find very hard to make it work. I tried to retrieve info by Id
and NAME
but it didn’t really work. I also inspected the html of the websites but didn’t really understand what to take it from it.
name_field = driver.find_element(By.NAME, 'Nome e Cognome')
name_field.send_keys(name)
NoSuchElementException: no such element: Unable to locate element: {"method":"css selector","selector":"[name="Nome e Cognome"]"}
(Session info: chrome=125.0.6422.61); For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
# Also tried something like this (but it didn't work either):
name_field = WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.NAME, 'Nome e Cognome')))
It would be helpful to have an example of what to do with the “click” option and with the “fill the form” option so that I understand better how to do it.
Can anyone help me with this?