I’m using sync Playwright to scrape football team stats from fbref.com, an example team page would be:
https://fbref.com/en/squads/8774e267/2024/matchlogs/all_comps/shooting/Hacken-Match-Logs-All-Competitions
I specifically had to switch from BeautifulSoup to Playwright to scrape the table that is revealed once you press the dark green button I’ve circled in red:
When inspected, the button reveals:
Normally I’d extract the href but as you can see it’s javascript:void(0)
I’ve tried:
<code>page.click(".sr_preset")</code><code>page.click(".sr_preset") </code>page.click(".sr_preset")
(which breaks the code) and:
<code>page.locator(f"//a[text()='Against {team_name}']").click()</code><code>page.locator(f"//a[text()='Against {team_name}']").click() </code>page.locator(f"//a[text()='Against {team_name}']").click()
which doesn’t change the table.
Could there be a way to extract ".assoc_matchlogs_against"
which I suppose is the table I need?
Or is there a way to click this button?
The code works fine otherwise, I can provide a sample if needed.