world athletics react year dropdown - pure cdp possible? #4234
-
|
This script is successful. Yet if sb.connect() is commented out, the click to change year does not complete. (see between the two blue arrows ⬇️ ) I've tested multiple times with different sb methods and no success. When I watch headed, I see the date change in the input field yet is not accepted and the table does not refresh. Thanks for your help folks! import argparse print("Starting ...") ATHLETE_URLS = [ def scrape_athlete(url, year): async def launch_with_delay(loop, executor, delay, url, year): async def scrape_all_async(urls, year): async def main(): if name == "main": |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Here are two different scripts that can do that. First one is with regular CDP Mode: from seleniumbase import SB
with SB(uc=True, test=True) as sb:
url = "https://worldathletics.org/athletes/united-states/cole-hocker-14905834"
sb.activate_cdp_mode(url)
sb.sleep(2)
sb.open("https://worldathletics.org/athletes/united-states/cole-hocker-14905834")
sb.click("button#CybotCookiebotDialogBodyLevelButtonLevelOptinAllowAll")
sb.click('button[value="STATISTICS"]')
sb.click('button[value="Results"]')
sb.sleep(1)
sb.click('[class*="athletesSelectInput_athletesSelectContainer"]')
sb.sleep(1)
sb.click('[class*="athletesSelectInput__menu-list"] div:contains("2025")')
sb.sleep(2)
print("Results:")
rows = sb.find_elements('tbody[class*="profileStatistics_tableBody"] tr')
for row in rows:
print("* " + row.text)And here's a script that does the same thing using the Pure CDP Mode format: from seleniumbase import sb_cdp
url = "https://worldathletics.org/athletes/united-states/cole-hocker-14905834"
sb = sb_cdp.Chrome(url)
sb.sleep(2)
sb.open("https://worldathletics.org/athletes/united-states/cole-hocker-14905834")
sb.click("button#CybotCookiebotDialogBodyLevelButtonLevelOptinAllowAll")
sb.click('button[value="STATISTICS"]')
sb.click('button[value="Results"]')
sb.sleep(1)
sb.click('[class*="athletesSelectInput_athletesSelectContainer"]')
sb.sleep(1)
sb.click('[class*="athletesSelectInput__menu-list"] div:contains("2025")')
sb.sleep(2)
print("Results:")
rows = sb.find_elements('tbody[class*="profileStatistics_tableBody"] tr')
for row in rows:
print("* " + row.text) |
Beta Was this translation helpful? Give feedback.
Here are two different scripts that can do that.
First one is with regular CDP Mode: