NikolayBezay

Example for April

Nov 5th, 2020 (edited)
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. console.log('===============Products from current page===============');
  2. var listAll = document.querySelectorAll('.products.row > div');
  3. for (var i = 0; i < 2; i++) {
  4.         console.log('product ',i, 'is: ', listAll[i]);
  5.         console.log("saleprice - ", listAll[i].querySelector(".saleprice"));
  6.         var price = listAll[i].querySelector(".special_price.text-center");
  7.         var oldPrice = listAll[i].querySelector(".oldprice");
  8.         console.log("all price wrapper- ", price);
  9.         console.log("all price text content- ", price.textContent);
  10.         var productId = "";
  11.         productId = price.id.replace("DIV", "");
  12.         var oldPrice = "#crntPrice" + productId;
  13.         console.log("oldPrice - ", listAll[i].querySelector(oldPrice));                  
  14.         console.log('===============product end===============');
  15. }
  16. console.log('=========================================================');
  17. console.log('=========================================================');
  18. console.log('==================waiting for data=======================');
  19. console.log('=========================================================');
  20.  
  21. var parser = new DOMParser();
  22. var doc = '';
  23. var data = null;
  24. var xhr = new XMLHttpRequest();
  25. xhr.withCredentials = true;
  26. xhr.addEventListener('readystatechange', function() {
  27.     if (this.readyState === 4) {
  28.         console.log('===============Products from this page by request===============');
  29.         doc = parser.parseFromString(this.responseText, 'text/html');
  30.         var listAll = doc.querySelectorAll('.products.row > div');
  31.         for (var i = 0; i < 2; i++) {
  32.                 console.log('product ',i, 'is: ', listAll[i]);
  33.                 console.log("saleprice - ", listAll[i].querySelector(".saleprice"));
  34.                 var price = listAll[i].querySelector(".special_price.text-center");
  35.                 var oldPrice = listAll[i].querySelector(".oldprice");
  36.                 console.log("all price wrapper- ", price);
  37.                 console.log("all price text content- ", price.textContent);
  38.                 var productId = "";
  39.                 productId = price.id.replace("DIV", "");
  40.                 var oldPrice = "#crntPrice" + productId;
  41.                 console.log("oldPrice - ", listAll[i].querySelector(oldPrice));                  
  42.                 console.log('===============product end===============');
  43.         }
  44.     }
  45. });
  46. xhr.open('GET', 'https://www.april.co.il/shoppingil2020');
  47. xhr.setRequestHeader('cache-control', 'no-cache');
  48. xhr.send(data);
Add Comment
Please, Sign In to add comment