Skip to content

Instantly share code, notes, and snippets.

@coodix
Last active December 16, 2015 07:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coodix/5402478 to your computer and use it in GitHub Desktop.
Save coodix/5402478 to your computer and use it in GitHub Desktop.
Array.prototype.getUnique = function(){
var u = {}, a = [];
for(var i = 0, l = this.length; i < l; ++i){
if(u.hasOwnProperty(this[i])) {
continue;
}
a.push(this[i]);
u[this[i]] = 1;
}
return a;
}
p = {};
$('a[href*="/cat.php?id_user="]').each (function() {
var flat_url = 'http://www.cian.ru' + $(this).closest('td.cat').find('a[href*="/showphoto.php?id_flat="]').attr('href');
var user_id = $(this).text();
p[user_id] = (typeof p[user_id] == "undefined") ? { phones: [], flats: [] } : p[user_id];
p[user_id].flats.push(flat_url);
var phones = p[user_id].phones;
$(this).closest('td.cat').siblings('td[id*="contacts"]').find('a.n').each(function() {
p[user_id].phones.push($(this).text());
});
p[user_id].phones = p[user_id].phones.getUnique();
}
)
//////////
JSON.stringify(p)
http://jsonformatter.curiousconcept.com/
//////////
$.get('/cat.php?deal_type=1&obl_id=10&city[0]=11622&type=2&room1=1&room2=1&room3=1&p=2', function(data){
$('table.cat tbody').append($(data).find('table.cat tbody tr'));
})
$.get('/cat.php?deal_type=1&obl_id=10&city[0]=11622&type=2&room1=1&room2=1&room3=1&p=3', function(data){
$('table.cat tbody').append($(data).find('table.cat tbody tr'));
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment