I’m working on a sports data project and need help with web scraping in Google Sheets. I want to pull basketball team statistics from online sources instead of manually checking multiple websites.
I discovered a site that displays team performance data with different time ranges. When I try using basic import functions like =IMPORTHTML("https://sportsstats.net/league-table.php","table",2), I get the entire data table imported successfully.
The problem is that the website has dropdown menus to filter results by recent games (last 5, 10, or 15 matches), but my import function doesn’t recognize these selections. Even when I manually choose “last 5 games” on the site, Google Sheets still imports the default full season data.
I also attempted using IMPORTXML with a specific path like =IMPORTXML("https://sportsstats.net/league-table.php","/html/body/main/section[2]/div[1]/table") but this doesn’t capture the filtered data either.
I’ve been learning about web scraping and understand browser developer tools basics, but I’m struggling with dynamic content. The dropdown selections seem to use JavaScript to update the table without changing the URL. Is there a way to import this filtered data using built-in Google Sheets functions, or do I need to write a custom Apps Script solution?
You’re hitting a client-side rendering wall - Google Sheets can’t handle that. I’ve been there with e-commerce sites where price filters mess with the content dynamically. Those dropdown changes happen after the page loads, but IMPORTHTML just grabs the raw server response before any JavaScript runs. Here’s what worked for me: check if the site has direct API endpoints or URL parameters for filtering. You might skip the dropdown completely by building URLs with query strings like ‘?filter=last5games’. Watch the network requests when you change filters manually - sometimes sites use GET requests to different endpoints instead of POST requests. If there’s no direct URL pattern, Apps Script with HtmlService can render JavaScript before scraping, but that’s way more complex than basic import functions.
Had this exact problem pulling financial data from sites with dropdown filters. IMPORTHTML and IMPORTXML only grab static HTML - they can’t handle the JavaScript that runs when you select dropdown options. Google Sheets functions run before any JavaScript loads, so they completely miss the filtered results.
No way around it with built-in functions. You need Apps Script. I wrote a script using UrlFetchApp to make POST requests with the filter parameters - basically copying what the dropdown does. Open developer tools, hit the network tab, and change the dropdown. You’ll see the AJAX requests with parameters you can copy into your script. More work than basic importing, but you get full control over what data you pull.
yeah, i feel your pain! sports sites do that a lot, making it tough for import functions. you should check the network tab while changing those dropdowns. often they hit specific API endpoints like /api/stats?games=5. finding those can help you import directly from them! also, maybe check the source code for hidden params.