Created
January 31, 2018 14:33
-
-
Save jakubbalada/2873fa22518978eec3047fe6e8fe1281 to your computer and use it in GitHub Desktop.
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
function pageFunction(context) { | |
// called on every page the crawler visits, use it to extract data from it | |
var $ = context.jQuery; | |
if (context.request.label === 'start') { | |
context.skipOutput(); | |
var count = parseInt($('.count').text()); | |
for(var i=0; i<=count; i+=20) { | |
context.enqueuePage("http://www.topshop.com/webapp/wcs/stores/servlet/CatalogNavigationAjaxSearchResultCmd?storeId=12556&catalogId=33057&langId=-1&dimSelected=%2Fen%2Ftsuk%2Fcategory%2Fclothing-427%2FN-82zZdgl%3FNo%3D" + i + "%26Nrpp%3D20%26siteId%3D%252F12556%26categoryId%3D203984"); | |
} | |
} else { | |
var jsonObject = JSON.parse($('body pre').text()); | |
return jsonObject.results.contents[0].records; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment