Created
November 14, 2015 19:39
-
-
Save Quenty/ebc24a047de6b8d12f95 to your computer and use it in GitHub Desktop.
Scrapes ROBLOX model sales for a user.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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