I am trying to grab some telephone no. from a website, I don't know why I keep getting the wrong information.
I am using jupyter to run the code
from selenium import webdriver
url = 'https://www.europages.co.uk/KIDDYSTORES/00000003902113-191369001.html'
tel = []
# Setup webdriver
driver = webdriver.Chrome('.\\chromedriver.exe')
driver.set_page_load_timeout(10)
driver.get(url)
driver.execute_script("window.scrollTo(0, 720)")
button = driver.find_elements_by_xpath('//*[@id="content"]/aside/div/div[1]/h3')[0]
# //*[@id="content"]/aside/div/div[1]/h3
button.click()
if len(driver.find_elements_by_xpath('//*[@id="content"]/aside/div/div[1]/div[6]/ul/li/div/a'))!=0:
button = driver.find_elements_by_xpath('//*[@id="content"]/aside/div/div[1]/div[6]/ul/li/div/a')[0]
elif len(driver.find_elements_by_xpath('//*[@id="content"]/aside/div/div[1]/div[7]/ul/li/div[1]/a'))!=0:
button = driver.find_elements_by_xpath('//*[@id="content"]/aside/div/div[1]/div[7]/ul/li/div[1]/a')[0]
elif len(driver.find_elements_by_xpath('//*[@id="content"]/aside/div/div[1]/div[6]/ul/li/div[1]/a'))!=0[0]:
button = driver.find_elements_by_xpath('//*[@id="content"]/aside/div/div[1]/div[6]/ul/li/div[1]/a')[0]
button.click()
print(driver.find_element_by_xpath('//*[@id="content"]/aside/div/div[1]/div[6]/ul/li/div/div').get_attribute('innerHTML'))
driver.find_element_by_xpath('//*[@id="content"]/aside/div/div[1]/div[6]/ul/li/div/div').get_attribute('innerHTML')
Above are the code I am running, I expect to get '+33 141 57 22 81', but the actual output is '\n\t\t\t\t\t\t\t'
print(driver.find_element_by_class_name('team-sh-tel').get_attribute('innerHTML'))
However, when I run the code individually in another cell in the jupyter it can prints out the desired phone no.