Advertisement
turist_ua

arab health

Jan 22nd, 2020
505
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. da_companies = [];
  2.  
  3. function httpGetAsync(url, callback) {
  4.     let xmlHttp = new XMLHttpRequest();
  5.     xmlHttp.onreadystatechange = function() {
  6.         if (xmlHttp.readyState == 4 && xmlHttp.status == 200) callback(xmlHttp.responseText);
  7.     };
  8.  
  9.     xmlHttp.open("GET", url, true); // true for asynchronous
  10.     xmlHttp.send(null);
  11. }
  12.  
  13. for (let i = 1; i <= 5; i++) {
  14.     let url = 'https://www.omnia-health.com/exhibitordirectory/arab-health?page=' + i + '&countryfield=GB&product_categories=15646'
  15.     httpGetAsync(url, (page) => {
  16.         let el = document.createElement('html');
  17.         el.innerHTML = page;
  18.  
  19.         var da_nodes = document.getElementsByClassName('node node-booth node-teaser view-mode-teaser');
  20.  
  21.         for (let i = 0; i < da_nodes.length; i++) {
  22.             let rows = [
  23.                 da_nodes[i].querySelector("div.booth-location-numbers"),
  24.                 da_nodes[i].querySelector("div.section-two > h3 > a"),
  25.                 da_nodes[i].querySelector("div.section-two > p")
  26.             ];
  27.  
  28.             booth = rows[0] && rows[0].innerText;
  29.             company = rows[1] && rows[1].innerText;
  30.             url = rows[1] && rows[1].href;
  31.             description = rows[2] && rows[2].innerText.replace(/[\W_]+/g," ");;
  32.  
  33.             company = [booth, company, url, description];
  34.  
  35.             da_companies.push(company.join(';'));
  36.         }
  37.     });
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement