Created
April 9, 2018 18:02
-
-
Save mkhizeryounas/341d55e859a3fe90b2daf15bc3a7a6eb to your computer and use it in GitHub Desktop.
Crawler for zameen.com made by apify.com
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) { | |
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(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you're looking for a more perfect Zameen.com API just use this RapidAPI: ZamBee | Zameen.com REST API