I wrote a code in selenium to extract number of Rounds in a soccer league, all elements are the same for all pages from what I can see but for some reason, the code works for some links and does not work for others.
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from time import sleep
def pack_links(l):
options = Options()
options.headless = True
driver = webdriver.Chrome()
driver.get(l)
rnds = driver.find_element_by_id('showRound')
a_ = rnds.find_elements_by_xpath(".//td[@class='lsm2']")
#a_ = driver.find_elements_by_class_name('lsm2')
knt = 0
for _ in a_:
knt = knt+1
print(knt)
sleep(2)
driver.close()
return None
link = 'http://info.nowgoal.com/en/League/34.html'
pack_links(link)
Here is a link that works Nowgoal Serie B, it returns the number of td
tags with class lsm2
and a picture of what the source page looks like
And this one return's 0,for some reason it does not find the tags with class lsm2
Nowgoal Serie A, and also a picture of the segment of interest
Even when I trying to find it directly with this commented line
a_ = driver.find_elements_by_class_name('lsm2')
it still returns 0. I will appreciate any help with this.