I would like to get all the tournament urls on here like following element
<a href="/en/tournament/m25-falun/swe/2021/m-itf-swe-04a-2021/">
They all share that they contain '/en/tournament/m' so this is what I tried
elems = driver.find_elements_by_css_selector("a[href*='/en/tournament/m']")
Anybody got an Idea here?
CodePudding user response:
wait=WebDriverWait(driver, 10)
driver.get('https://www.itftennis.com/en/tournament-calendar/mens-world-tennis-tour-calendar/?startdate=2021-10')
##wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "#onetrust-close-btn-container > button"))).click()
titles=wait.until(EC.presence_of_all_elements_located((By.CSS_SELECTOR, "a[href*='/en/tournament/m']")))
for title in titles:
print(title.get_attribute("href"))
Generally we wait for all the elements to pop up and then get the attribute href.
Import
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
Outputs
https://www.itftennis.com/en/tournament/m25-falun/swe/2021/m-itf-swe-04a-2021/
https://www.itftennis.com/en/tournament/m25-pretoria/rsa/2021/m-itf-rsa-03a-2021/
https://www.itftennis.com/en/tournament/m25-skopje/mkd/2021/m-itf-mkd-03a-2021/
https://www.itftennis.com/en/tournament/m25-budapest/hun/2021/m-itf-hun-01a-2021/
https://www.itftennis.com/en/tournament/m15-cancun/mex/2021/m-itf-mex-02a-2021/
https://www.itftennis.com/en/tournament/m15-monastir/tun/2021/m-itf-tun-39a-2021/
https://www.itftennis.com/en/tournament/m15-lubbock-tx/usa/2021/m-itf-usa-15a-2021/
https://www.itftennis.com/en/tournament/m15-cairo/egy/2021/m-itf-egy-25a-2021/
https://www.itftennis.com/en/tournament/m15-forbach/fra/2021/m-itf-fra-13a-2021/
https://www.itftennis.com/en/tournament/m25-nevers/fra/2021/m-itf-fra-14a-2021/
https://www.itftennis.com/en/tournament/m25-lima/per/2021/m-itf-per-01a-2021/
https://www.itftennis.com/en/tournament/m25-setubal/por/2021/m-itf-por-13a-2021/
https://www.itftennis.com/en/tournament/m25-prague/cze/2021/m-itf-cze-08a-2021/
https://www.itftennis.com/en/tournament/m15-doha/qat/2021/m-itf-qat-01a-2021/
https://www.itftennis.com/en/tournament/m15-ithaca-ny/usa/2021/m-itf-usa-16a-2021/
https://www.itftennis.com/en/tournament/m15-cancun/mex/2021/m-itf-mex-03a-2021/
https://www.itftennis.com/en/tournament/m15-monastir/tun/2021/m-itf-tun-40a-2021/
https://www.itftennis.com/en/tournament/m15-naples-fl/usa/2021/m-itf-usa-21a-2021/
https://www.itftennis.com/en/tournament/m15-sozopol/bul/2021/m-itf-bul-04a-2021/
https://www.itftennis.com/en/tournament/m15-platja-daro/esp/2021/m-itf-esp-13a-2021/
https://www.itftennis.com/en/tournament/m15-sharm-el-sheikh/egy/2021/m-itf-egy-26a-2021/
https://www.itftennis.com/en/tournament/m25-lima/per/2021/m-itf-per-02a-2021/
https://www.itftennis.com/en/tournament/m25-loule/por/2021/m-itf-por-14a-2021/
https://www.itftennis.com/en/tournament/m25plush-rodez/fra/2021/m-itf-fra-15a-2021/
https://www.itftennis.com/en/tournament/m15-doha/qat/2021/m-itf-qat-02a-2021/
https://www.itftennis.com/en/tournament/m15-kazan/rus/2021/m-itf-rus-06a-2021/
https://www.itftennis.com/en/tournament/m15-cancun/mex/2021/m-itf-mex-04a-2021/
https://www.itftennis.com/en/tournament/m15-monastir/tun/2021/m-itf-tun-41a-2021/
https://www.itftennis.com/en/tournament/m15-platja-daro/esp/2021/m-itf-esp-14a-2021/
https://www.itftennis.com/en/tournament/m15-sharm-el-sheikh/egy/2021/m-itf-egy-27a-2021/
https://www.itftennis.com/en/tournament/m15-naples-fl/usa/2021/m-itf-usa-22a-2021/
https://www.itftennis.com/en/tournament/m15-antalya/tur/2021/m-itf-tur-27a-2021/
https://www.itftennis.com/en/tournament/m15-sozopol/bul/2021/m-itf-bul-02a-2021/
https://www.itftennis.com/en/tournament/m25-rio-do-sul/bra/2021/m-itf-bra-03a-2021/
https://www.itftennis.com/en/tournament/m25-nur-sultan/kaz/2021/m-itf-kaz-10a-2021/
https://www.itftennis.com/en/tournament/m25-hamburg/ger/2021/m-itf-ger-11a-2021/
https://www.itftennis.com/en/tournament/m25-quinta-do-lago/por/2021/m-itf-por-15a-2021/
https://www.itftennis.com/en/tournament/m25-toulouse/fra/2021/m-itf-fra-16a-2021/
https://www.itftennis.com/en/tournament/m15-doha/qat/2021/m-itf-qat-03a-2021/
https://www.itftennis.com/en/tournament/m15-vero-beach-fl/usa/2021/m-itf-usa-17a-2021/
https://www.itftennis.com/en/tournament/m15-sharm-el-sheikh/egy/2021/m-itf-egy-28a-2021/
https://www.itftennis.com/en/tournament/m15-girona/esp/2021/m-itf-esp-19a-2021/
https://www.itftennis.com/en/tournament/m15-cancun/mex/2021/m-itf-mex-05a-2021/
https://www.itftennis.com/en/tournament/m15-monastir/tun/2021/m-itf-tun-42a-2021/
https://www.itftennis.com/en/tournament/m15-antalya/tur/2021/m-itf-tur-28a-2021/
https://www.itftennis.com/en/tournament/m25-sarreguemines/fra/2021/m-itf-fra-17a-2021/
https://www.itftennis.com/en/tournament/m25-calabasas-ca/usa/2021/m-itf-usa-19a-2021/
https://www.itftennis.com/en/tournament/m25-guayaquil/ecu/2021/m-itf-ecu-03a-2021/
https://www.itftennis.com/en/tournament/m25-nur-sultan/kaz/2021/m-itf-kaz-11a-2021/
https://www.itftennis.com/en/tournament/m25-portimao/por/2021/m-itf-por-16a-2021/
https://www.itftennis.com/en/tournament/m15-parnu/est/2021/m-itf-est-02a-2021/
https://www.itftennis.com/en/tournament/m15-tallahassee-fl/usa/2021/m-itf-usa-20a-2021/
https://www.itftennis.com/en/tournament/m15-monastir/tun/2021/m-itf-tun-43a-2021/
https://www.itftennis.com/en/tournament/m15-madrid/esp/2021/m-itf-esp-24a-2021/
https://www.itftennis.com/en/tournament/m15-antalya/tur/2021/m-itf-tur-29a-2021/
https://www.itftennis.com/en/tournament/m15-selva-gardena/ita/2021/m-itf-ita-11a-2021/
https://www.itftennis.com/en/tournament/m15-sharm-el-sheikh/egy/2021/m-itf-egy-29a-2021/