Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
//Extract Google Trends topics
//Usage: copy and paste in Chrome Javascript console with trending pages open. for example:
function getTopics(){
topics_anchors = document.querySelectorAll("div.details-wrapper > div.details > div.details-bottom > div.subtitles-text-wrapper.visible > div.summary-text > a");
var topics = [];
for (topic of topics_anchors){
return topics;
#example output:
#["blink-182 & Lil Wayne announce co-headlining tour", "Duchess Meghan's royal baby is here and it's a boy, Buckingham Palace says", "Bookmakers suspend betting on royal baby birthdate amid speculation that Meghan has given birth", "Microsoft open-sources its quantum computing development tools", "Giants vs. Reds odds, line: MLB picks, predictions for May 6 from model on 73-51 roll", "St. Charles levee breach prompts evacuations", "Gina Rodriguez Marries Longtime Love Joe LoCicero", "Spider-Man: Far From Home's new trailer spoils Avengers: Endgame, explodes the MCU", "Wall Street falls after Trump's China tariff threat", "Wendy's is bringing back its spicy chicken nuggets…eet racked up more than 2 million likes in 2 days", "China State Funds Sought to Cushion Blow as Stocks Tumble", "S&P Metals & Mining SPDR (XME) Looking To Gain Traction: What the Technicals Reveal", "Sunscreens may enter bloodstream, but health effect unknown, study finds"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment