Reputation: 453
I am trying to write a script to scrape data from this website.
I tried running a block of code below.
from selenium import webdriver
import time
driver = webdriver.Chrome(executable_path='C:/Users/blackwidow/Desktop/USHL data scraping/chromedriver.exe')
url = ("https://www.ushl.com/view#/schedule")
driver.get(url)
driver.find_element_by_xpath("//select[@ng-model ='selectedSeason']/option[@label='2019-20']").click()
time.sleep(3)
driver.find_element_by_xpath("//select[@ng-model ='selectedTeam']/option[@label='Youngstown Phantoms']").click()
time.sleep(3)
It worked perfectly up to this point.
Then, I needed to click the button named 'Submit,' which is defined as follows:
<a href="" class="ht-btn-submit ng-binding" ng-click="getSeasonSchedule();">SUBMIT</a>
I tried the following line of code
driver.find_element_by_xpath("//span[@ng-click=\'getSeasonSchedule();']").click()
which did not work.
I have tried the following, to no avail.
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH,
"//div[@class='ht-col-left']//a[contains(@href, '')]/span[@ng-
click=\'getSeasonSchedule();']"))).click()
Upvotes: 0
Views: 513
Reputation: 2227
Use this for the Submit button.
driver.find_element_by_xpath('//a[@class="ht-btn-submit ng-binding"]').click()
Upvotes: 1