A Node.js scraper that extracts trending topics and related data from Google Trends using Puppeteer. This tool scrapes trending search terms, search volumes, related links, and trending breakdowns for multiple regions.
- Scrapes trending topics from Google Trends
- Supports multiple regions (UK, US, France, Spain, Germany, Argentina, Brazil)
- Extracts search volume, trending terms, and related links
- Uses headless browser automation with Puppeteer
- Worked fine using Github actions to run it daily
- Node.js (v14 or higher recommended)
- npm (comes with Node.js)
- Clone the repository:
git clone <repository-url>
cd google-trends-scraper- Install dependencies:
npm installThe scraper can be run for different regions. By default, it's configured to run for the UK region.
-
Edit the region in
index.js:At the bottom of
index.js, uncomment the region you want to scrape:runAll('uk'); // United Kingdom // runAll('us'); // United States // runAll('fr'); // France // runAll('es'); // Spain // runAll('de'); // Germany // runAll('ar'); // Argentina // runAll('br'); // Brazil
-
Run the scraper:
node index.jsuk- United Kingdomus- United Statesfr- Francees- Spainde- Germanyar- Argentinabr- Brazil
The scraper returns an array of objects, each containing:
{
updatedAt: "2024-01-15T10:30:00.000Z", // ISO timestamp
searchBy: "Trending Topic Title", // Main trending topic
links: ["url1", "url2", ...], // Array of related links
searchVolume: "100K+", // Search volume indicator
country: "uk", // Region code
createdAt: "01/15/2024", // Formatted date
trendingTerms: ["term1", "term2", ...] // Array of related trending terms
}- Launches a headless Chrome browser using Puppeteer
- Navigates to the Google Trends page for the selected region
- Waits for the trending topics table to load
- Clicks on each trending item to expand details
- Extracts:
- Topic title
- Search volume
- Trending breakdown terms
- Related article links
- Returns all extracted data as a structured array
- The scraper uses a headless browser, so it may take some time to complete
- Google Trends pages may change their structure, which could require updates to the selectors
- The scraper waits for network idle to ensure all content is loaded
- Make sure you have a stable internet connection when running the scraper