linkedin bot by adding people automatically

I try to learn the web scraping by using nodejs and nightmarejs.

I wanted to create a bot that can connect to my linkedin account, then look for a technology, as javascript for example, then add the link of each profile in the sheet into a table, and with this table, I wanted to use a loop with "for" to click on the each link. At the end I send an invitation for each profile on the sheet.

Here my code :

var Nightmare = require('nightmare');
var nightmare = Nightmare({ show: true })

 var langage = process.argv[2];

 var urls = [];
    .viewport(1000, 720)
    .type('#login-email', '**********')
    .type('#login-password', '*********')
    .type('#main-search-box', langage)
    .evaluate(function () {
 var link = [];
    $('.primary-action-button.label').each(function(i, item) {
    urls = link;


.run(function (err, nightmare) {
if (err) return console.log(err);

for (var i = 0; i< urls.length; i++ ) {


I type node script.js ‘jquery’ into the console and it told me that ‘urls is not defined’, and I don’t undestand where is my mistake.
If you can help me, it would be really helpful 🙂
Thank you,


67 thoughts on “linkedin bot by adding people automatically”

Leave a Comment