Skip to content
Advertisement

Selenium element is not attached to the page document

I am trying to scrape this particular site with Python: https://www.milanofinanza.it/quotazioni/ricerca/listino-completo-2ae?refresh_cens.

I need to get all the isin codes and the names. My idea was to get them all in 2 separated lists, to do that I try to get the entire column (by changing the Xpath to tr rather than tr1) and then add it to the list.

My code goes through the pages but at a certain point just stop working (even if I add time.sleep(10) to be sure that the code starts scraping when the site is fully loaded).

My code looks like this:

JavaScript

How can I solve this problem? Here some pictures to better understand:

Name:

enter image description here

Isin:

enter image description here

Advertisement

Answer

I’m sorry, but I can’t see how your existing code is working.
On my side I see the locator you are using for isin matching nothing.
I have updated locators here.
I would advice you never using automatically created locators.
Also the code you presenting here is missing indentations. I hope your actual code having proper indentations.
Please see if this will work better:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement