Skip to content

Instantly share code, notes, and snippets.

@mkhizeryounas
Created April 9, 2018 18:02
Show Gist options
  • Save mkhizeryounas/341d55e859a3fe90b2daf15bc3a7a6eb to your computer and use it in GitHub Desktop.
Save mkhizeryounas/341d55e859a3fe90b2daf15bc3a7a6eb to your computer and use it in GitHub Desktop.
Crawler for zameen.com made by apify.com
function pageFunction(context) {
var $ = context.jQuery;
var __PAGES = parseInt($('li[title="Last"]').data('val'));
// var __PAGES = 5;
console.log(__PAGES)
var result = [];
var extractData = function(page) {
if( page < __PAGES ) {
var api = 'https://beta.zameen.com/Homes/Lahore-1-'+page+'.html';
console.log(api)
$.ajax({
url: api,
type: 'GET',
}).success (function(data) {
$(data).find('.listig-card-outter').each(function(){
var item = {
link: $(this).find('a').attr('href'),
title: $(this).find('.title').text(),
price: parseInt($(this).find('.amount').data('def_price')),
img: $(this).find('img').attr('src')
};
result.push(item);
});
extractData(++page);
}).fail(function(xhr, textStatus, errorThrown) {
context.finish();
});
} else {
context.finish(result);
}
};
extractData(0);
// console.log(context)
context.willFinishLater();
}
@subtainishfaq7175
Copy link

This is great, how can we discuss more about it ?

@theshahzaibc
Copy link

If you're looking for a more perfect Zameen.com API just use this RapidAPI: ZamBee | Zameen.com REST API

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment