Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let da_companies = [];
- function httpGetAsync(url, callback) {
- let xmlHttp = new XMLHttpRequest();
- xmlHttp.onreadystatechange = function() {
- if (xmlHttp.readyState == 4 && xmlHttp.status == 200) callback(xmlHttp.responseText);
- };
- xmlHttp.open("GET", url, true); // true for asynchronous
- xmlHttp.send(null);
- }
- for(let i=1; i <=6; i++){
- let url = 'https://www.icelondon.uk.com/2019-exhibitors?page=' + i + '&filters.STATUS=,Enhanced%20-%20Featured,Featured,Enhanced,Basic#/'
- httpGetAsync(url, (page) => {
- let el = document.createElement( 'html' );
- el.innerHTML = page;
- let companies = el.getElementsByClassName('m-exhibitors-list__items__item__body__name__link');
- //console.log(companies);
- for(let j = 0; j < companies.length; j++){
- let c = {
- name: companies[j].text.trim(),
- url: companies[j].href
- };
- httpGetAsync(c.url, (cpage) => {
- let el2 = document.createElement('html');
- el2.innerHTML = cpage;
- c.email = el2.getElementsByClassName('m-exhibitor-entry__item__body__contacts__additional__button__mail')[0].children[0].href.replace('mailto:', '');
- c.linkedin = '';
- let social = el2.getElementsByClassName('m-exhibitor-entry__item__body__contacts__additional__social')[0].children;
- for (let item of social) {
- var link = item.getElementsByTagName('a')[0].href; link.indexOf('linkedin') > 0 && (c.linkedin = link)
- }
- c.website = el2.getElementsByClassName('m-exhibitor-entry__item__body__contacts__additional__button__website')[0].children[0].href;
- c.country = el2.getElementsByClassName('m-exhibitor-entry__item__body__contacts__address')[0].innerHTML.split('<br>');
- c.country = c.country[c.country.length-1].trim();
- });
- da_companies.push(c);
- }
- });
- }
- ////////////////////
- let resp = [];
- da_companies.forEach(c => {
- resp.push([c.name, c.url, c.email, c.linkedin, c.website, c.country].join(';'));
- });
- ////////////////////
- console.log(resp.join('\n'));
Add Comment
Please, Sign In to add comment