1
1
13-Floky2018-07-20 07:17:01
Parsing
13-Floky, 2018-07-20 07:17:01

How to display a link from parsing in NODEJS?

Help out guys.
I'm doing something like a parse, below is the code:

const osmosis = require('osmosis');
const fs = require('fs');
let savedData = [];
osmosis


   .get('https://##########//profi')
   .find('.user-preview')
   .set({
           'Name': '.user-preview_name',
     'Specialization': '.user-preview_specialization',
  	   'City': '.user-preview_city',
     'URL': '.data-url',
    })

    
  .data(function(data) {
      console.log(data);
      savedData.push(data);
   })
   .done(function() {
      fs.writeFile('data.json', JSON.stringify( savedData, null, 4), function(err) {
        if(err) console.error(err);
        else console.log('Data Saved to data.json file');
      })
   });

The trouble is that everything works fine, but the MOST IMPORTANT thing is how to get me user-contacts, i.e. do not SHOW CONTACTS BUT THE NAME LINK TO CONTACTS
<div class="user-contacts" data-component="userContacts" data-url="https://www.###########/contacts" data-component-ready="true"><a class="js-userContactsShow" href="#">Показать контакты</a></div>

And not the main one yet, but the same question, how to make the parser, namely ( .get(' https://##########//profi ') catches not only one page, but say /profi/2 /profi/3 /profi/4

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
Javid Alimli, 2019-07-04
@jdava

I was looking for this answer myself and finally found it.
if you need to take values ​​from which "tag" then before the name you just need to insert @ - dog and then the name of the "tag", for example @href

K
Konstantin   , 2020-01-18
@SynCap

Option 1: stupidly follow the link

.follow('[email protected]')
.find(.....)
.set(.....)
....

Option 2: if there is a pop-up button with ajaxammi, then we simulate a click
.click('.js-userContactsShow')
.delay(500)
.find(......)
.set(.....)
....

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question