Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const request = require('request');
- const cheerio = require('cheerio');
- var url = 'https://www.coolshop.de/sitemap.xml';
- //First loop
- request(url,
- (error, response, html) => {
- if(!error && response.statusCode == 200) {
- var array = [];
- const $ = cheerio.load(html, {xmlMode: true});
- links = $('loc');
- $(links).each(function(i, link) {
- // var loc = $(link).attr('loc');
- //array.push(loc);
- // console.log($(link).text());
- var jrl = ($(link).text());
- //Second loop
- request(jrl,
- (error, response, html) => {
- if(!error && response.statusCode == 200) {
- const $ = cheerio.load(html, {xmlMode: true});
- linx = $('loc');
- $(linx).each(function(i, link) {
- // console.log($(link).text());
- var hrl = ($(link).text());
- //Third loop
- request(hrl,
- (error, response,html) => {
- if(!error && response.statusCode == 200) {
- const $ = cheerio.load(html);
- const id = $('#attributeSku');
- const name = $('.thing-header');
- const description = $('.thing.descriptions');
- //Ovo je deo koji ne radi
- const photo = $('.thing-cover__image gallery-item').attr('href');
- const firstPrice = $('.thing-buy-box-price price-with-decimal-large price');
- const secondPrice = $('.after-decimal');
- const output = photo;
- //Ovde sam svasta probao
- console.log(($(photo).text());
- }
- });
- });
- }
- });
- });
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement