Advertisement
xickoh

Postman

Jan 15th, 2020
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. #Worten
  2. var smartphone = [];
  3.  
  4. $('#products-list-block .w-product').each(function(k,v){
  5. smartphone.push({
  6. "name" : $(this).find(".w-product__title").text().replace(/ *\([^)]*\) */g, ""),
  7. "brand" : $(this).data('brand');
  8. "pageUrl": $(this).find(".w-product__url").attr("href"),
  9. "price": $(this).find(".w-currentPrice.iss-current-price .w-product-price__main").text() + "." + $(this).find(".w-currentPrice.iss-current-price .w-product-price__dec").text(),
  10. "details" : $(this).find(".w-product__title").text().match(/\(([^)]+)\)/)[1],
  11. "imgUrl" : "http://www.worten.pt" + $(this).find("img").attr("data-src"),
  12. "dateTime" : new Date().getTime(),
  13. "store" : "worten",
  14. });
  15. });
  16.  
  17. #Fnac
  18.  
  19. var $ = cheerio.load(responseBody);
  20.  
  21. var smartphone = [];
  22.  
  23. $(".Article-item").each(function(){
  24. let title = $(this).find(".Article-title").text().replace('Smartphone', '').trim();
  25. smartphone.push({
  26. "name" : title.substring(0, title.indexOf('-')).trim(),
  27. "pageUrl" : $(this).find(".Article-title").attr('href'),
  28. "price": $(this).find(".floatl .userPrice").text().replace(/\,/g, '.').replace(/[^0-9/.]/gi, ''),
  29. "details" : title.split(/-(.+)/)[1].trim(),
  30. "imgUrl" : $(this).find("img").attr("src"),
  31. "dateTime" : new Date().getTime(),
  32. "store" : "fnac",
  33. });
  34. });
  35.  
  36. pm.environment.set("fnac", JSON.stringify(smartphone));
  37.  
  38. console.log(smartphone);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement