Skip to content

Instantly share code, notes, and snippets.

@fastfingertips
Created January 8, 2024 05:19
Show Gist options
  • Save fastfingertips/531029e150080da79542c29cf2099ca4 to your computer and use it in GitHub Desktop.
Save fastfingertips/531029e150080da79542c29cf2099ca4 to your computer and use it in GitHub Desktop.
rotten tomatoes guide list scraper
const axios = require('axios');
const cheerio = require('cheerio');
const guide_url = "";
if (guide_url == "") {
console.log("Please set the guide_url variable to the url of the guide you want to scrape.");
return;
}
axios.get(guide_url)
.then(response => {
const $ = cheerio.load(response.data);
const movieTitles = $(".article_movie_title");
let allTitles = [];
for (let i = 0; i < movieTitles.length; i++) {
const title = $(movieTitles[i]).text().trim();
titleList = title.split(" ");
movie_name = titleList[0].split("(")[0].trim();
movie_year = titleList[0].split("(")[1].split(")")[0].trim();
movie_score = titleList[1].split("%")[0].trim();
allTitles.push({
"movie_name": movie_name, "movie_year": movie_year, "movie_score": movie_score
});
}
console.log(allTitles);
})
.catch(error => {
console.log(error);
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment