Skip to content

Instantly share code, notes, and snippets.

@Quenty
Created November 14, 2015 19:39
Show Gist options
  • Save Quenty/ebc24a047de6b8d12f95 to your computer and use it in GitHub Desktop.
Save Quenty/ebc24a047de6b8d12f95 to your computer and use it in GitHub Desktop.
Scrapes ROBLOX model sales for a user.
// Will pull off items on a page and repeat until it runs out of pages.
var numberOfPagesToScrape = 10;
function scrapePage(page) {
var count = 0, salesTotal = 0;
$(page).find("div.CatalogHoverContent div:contains(Sales)").has(".CatalogItemInfoLabel").each(function(index, object) {
var sales = $(object).find(".HoverInfo");
sales.each(function(index, actualSalesObject) {
var sold = parseInt($(actualSalesObject).text().replace(/,/g, ''))
salesTotal += sold;
});
});
return salesTotal;
}
function nextPage() {
$(".pager.next").trigger("click");
}
var totalSales = 0;
$(document).ajaxComplete(function() {
var salesOnPage = scrapePage(document);
var pageOn = ($("input.Paging_Input.translate").prop("value"));
totalSales += salesOnPage
console.log("On page: ", pageOn);
console.log("Sales on page: ", salesOnPage, "Total sales", totalSales);
if (pageOn < numberOfPagesToScrape) {
nextPage();
}
})
totalSales = scrapePage(document);;
console.log(totalSales);
nextPage();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment