Skip to content

Instantly share code, notes, and snippets.

@jakubbalada
Last active January 31, 2018 00:05
Show Gist options
  • Save jakubbalada/055810df04f813c2e2f46948521e534b to your computer and use it in GitHub Desktop.
Save jakubbalada/055810df04f813c2e2f46948521e534b to your computer and use it in GitHub Desktop.
function pageFunction(context) {
// called on every page the crawler visits, use it to extract data from it
var $ = context.jQuery;
if (context.request.label === 'detail') {
context.skipLinks();
// return data from internal JS variable
return property;
} else {
context.skipOutput();
// enqueue next pages in pagination
$('a.search-list__pagination-link').each(function(){
var url = "https://www.booli.se" + $(this).attr('href');
context.enqueuePage(url);
});
// enqueue all properties from current page
$('.search-list:not(.search-list--projects) .search-list__item').each(function(){
var url = "https://www.booli.se" + $(this).find('a').attr('href');
context.enqueuePage(url);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment