Web scraping with Selenium

前端 未结 2 904
独厮守ぢ
独厮守ぢ 2021-01-07 08:55

I\'m trying to scrape this website for the list of company names, code, industry, sector, mkt cap, etc in the table with selenium. I\'m new to it and have writt

2条回答
  •  灰色年华
    2021-01-07 09:29

    This is totally do-able. What might be the easiest is to use a 'find_elements' call (note that it's plural) and grab all of the elements. It will return a list that you can parse using find element (singular) calls on each one in the list, but this time find each element by class.

    You may be running into a timing issue. I noticed that the data you are looking for loads VERY slowly. You probably need to wait for that data. The best way to do that will be to check for its existence until it appears, then try to load it. Find elements calls (again, note that I'm using the plural again) will not throw an exception when looking for elements and finding none, it will just return an empty list. This is a decent way to check for the data to appear.

提交回复
热议问题