Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //getItems('https://m.avito.ru/moskva?pmax=60000&pmin=30000&q=21099')
- function getItems(url){
- $.ajax({
- type: "GET",
- url: url,
- success: function(pageStr) {
- var itemsCount = $($.parseHTML(pageStr)).find('.nav-helper-text').text();
- var items = $($.parseHTML(pageStr)).find('article.b-item:not(.item-vip):not(.item-highlight)');
- var itemsResult = [];
- items.each(function(item){
- var itemTitle = $(this).find('span.header-text').text();
- if ( $(this).find('span.pseudo-img').length ) {
- itemImg = $(this).find('span.pseudo-img').attr('style');
- };
- itemAvitoId = $(this).attr('data-item-id');
- itemAvitoDatetime = $(this).find('div.info-date').text().trim();
- itemsResult.push({
- title:itemTitle,
- img:itemImg,
- avitoid:itemAvitoId,
- datetime:itemAvitoDatetime
- });
- })
- console.log(JSON.stringify(itemsResult));
- console.log(itemsCount);
- },
- statusCode: {
- 403: function(res) {
- console.log('got 403.banned')
- }
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement