turist_ua

ICE totally gaming

Nov 29th, 2017
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let 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 <=6; i++){
  14.     let url = 'https://www.icelondon.uk.com/2019-exhibitors?page=' + i + '&filters.STATUS=,Enhanced%20-%20Featured,Featured,Enhanced,Basic#/'
  15.     httpGetAsync(url, (page) => {
  16.         let el = document.createElement( 'html' );
  17.         el.innerHTML = page;
  18.  
  19.         let companies = el.getElementsByClassName('m-exhibitors-list__items__item__body__name__link');
  20. //console.log(companies);
  21.         for(let j = 0; j < companies.length; j++){
  22.             let c = {
  23.                 name: companies[j].text.trim(),
  24.                 url: companies[j].href
  25.             };
  26.  
  27.             httpGetAsync(c.url, (cpage) => {
  28.                 let el2 = document.createElement('html');
  29.  
  30.                 el2.innerHTML = cpage;
  31.  
  32.                 c.email = el2.getElementsByClassName('m-exhibitor-entry__item__body__contacts__additional__button__mail')[0].children[0].href.replace('mailto:', '');
  33.                 c.linkedin = '';
  34.                 let social = el2.getElementsByClassName('m-exhibitor-entry__item__body__contacts__additional__social')[0].children;
  35.                 for (let item of social) {
  36.                     var link = item.getElementsByTagName('a')[0].href; link.indexOf('linkedin') > 0 && (c.linkedin = link)
  37.                 }
  38.                 c.website = el2.getElementsByClassName('m-exhibitor-entry__item__body__contacts__additional__button__website')[0].children[0].href;
  39.                 c.country = el2.getElementsByClassName('m-exhibitor-entry__item__body__contacts__address')[0].innerHTML.split('<br>');
  40.                 c.country = c.country[c.country.length-1].trim();
  41.             });
  42.             da_companies.push(c);
  43.         }
  44.     });
  45. }
  46.  
  47. ////////////////////
  48. let resp = [];
  49.  
  50. da_companies.forEach(c => {
  51.     resp.push([c.name, c.url, c.email, c.linkedin, c.website, c.country].join(';'));
  52. });
  53.  
  54.  
  55. ////////////////////
  56. console.log(resp.join('\n'));
Add Comment
Please, Sign In to add comment