Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2016
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 1.36 KB | None | 0 0
  1. //getItems('https://m.avito.ru/moskva?pmax=60000&pmin=30000&q=21099')
  2. function getItems(url){
  3.         $.ajax({
  4.         type: "GET",
  5.         url: url,
  6.         success: function(pageStr) {
  7.             var itemsCount = $($.parseHTML(pageStr)).find('.nav-helper-text').text();
  8.             var items = $($.parseHTML(pageStr)).find('article.b-item:not(.item-vip):not(.item-highlight)');
  9.             var itemsResult = [];
  10.             items.each(function(item){
  11.            
  12.                 var itemTitle = $(this).find('span.header-text').text();
  13.  
  14.                 if ( $(this).find('span.pseudo-img').length ) {
  15.                     itemImg = $(this).find('span.pseudo-img').attr('style');  
  16.                 };
  17.                
  18.                 itemAvitoId = $(this).attr('data-item-id');
  19.                 itemAvitoDatetime = $(this).find('div.info-date').text().trim();
  20.  
  21.                 itemsResult.push({
  22.                     title:itemTitle,
  23.                     img:itemImg,
  24.                     avitoid:itemAvitoId,
  25.                     datetime:itemAvitoDatetime
  26.                 });    
  27.                  
  28.  
  29.             })
  30.             console.log(JSON.stringify(itemsResult));
  31.             console.log(itemsCount);
  32.         },
  33.         statusCode: {
  34.             403: function(res) {
  35.                 console.log('got 403.banned')
  36.             }
  37.         }
  38.     });
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement