Ranork / Auto-Linkedin

Unoffical Linkedin Client NPM Package (Developed with Puppeteer)
https://www.npmjs.com/package/auto-linkedin
GNU General Public License v3.0
19 stars 2 forks source link

LinkedIn is not a constructor(looks like i am missing correct import) #3

Open dileepmaurya87 opened 3 weeks ago

dileepmaurya87 commented 3 weeks ago

I am facing this issue while running code

const client = new LinkedIn(); ^

TypeError: LinkedIn is not a constructor at Object. (//index.js:2:16) at Module._compile (node:internal/modules/cjs/loader:1376:14) at Module._extensions..js (node:internal/modules/cjs/loader:1435:10) at Module.load (node:internal/modules/cjs/loader:1207:32) at Module._load (node:internal/modules/cjs/loader:1023:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12) at node:internal/main/run_main_module:28:49

Ranork commented 3 weeks ago

import it via this code

// for cjs
const { LinkedIn } = require('auto-linkedin');

//for es6
import { LinkedIn } from 'auto-linkedin'
dileepmaurya87 commented 3 weeks ago

Getting this error for (const char of text) { ^

TypeError: text is not iterable at CdpKeyboard.type (/Users/dileepmaurya/Documents/advansappz/dripify-linkedin/node_modules/auto-linkedin/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/Input.js:129:28) at CdpElementHandle.type (/Users/dileepmaurya/Documents/advansappz/dripify-linkedin/node_modules/auto-linkedin/node_modules/puppeteer-core/lib/cjs/puppeteer/api/ElementHandle.js:921:46) at async CdpElementHandle. (/Users/dileepmaurya/Documents/advansappz/dripify-linkedin/node_modules/auto-linkedin/node_modules/puppeteer-core/lib/cjs/puppeteer/api/ElementHandle.js:268:32) at async LinkedIn.login (/Users/dileepmaurya/Documents/advansappz/dripify-linkedin/node_modules/auto-linkedin/src/controllers/linkedin.js:95:5) at async getLinkedInProfiles (/Users/dileepmaurya/Documents/advansappz/dripify-linkedin/index.js:5:5)

Below is my code snippet const { LinkedIn } = require('auto-linkedin'); const client = new LinkedIn(); const getLinkedInProfiles = async () => { await client.login(process.env.USERNAME, process.env.PASSWORD); const profiles = await client.searchPeople({ keywords: 'venture capital', network: ['S'] }, 200); console.log(profiles); }

getLinkedInProfiles();

Ranork commented 3 weeks ago

replace process.env.USERNAME to your email adres and process.env.PASSWORD to your password

dileepmaurya87 commented 3 weeks ago

Now I am recieving this Let’s do a quick verification -> The login attempt seems suspicious. To finish signing in please enter the verification code we sent to your email address.

Ranork commented 3 weeks ago

this means linkedin sends a challange to accept you to login. in the client option write headless false. For example:

const { LinkedIn } = require("../src/main")
const client = new LinkedIn({ headless: false })
//.... rest of your code

headless: false option shows the automated browser to you. Once you get ower the challange the cache will be set and not need to run headless anymore.

dileepmaurya87 commented 3 weeks ago

Now I am facing this Logged in from cache. [TASK] Search People: 200 ({"keywords":"software","network":["S"]}) TimeoutError: Waiting for selector .linked-area failed: Waiting failed: 30000ms exceeded at new WaitTask (/Users/Documents/node_modules/auto-linkedin/node_modules/puppeteer-core/lib/cjs/puppeteer/common/WaitTask.js:50:34) at IsolatedWorld.waitForFunction (/Users/Documents/node_modules/auto-linkedin/node_modules/puppeteer-core/lib/cjs/puppeteer/api/Realm.js:25:26) at CSSQueryHandler.waitFor (/Users/Documents/node_modules/auto-linkedin/node_modules/puppeteer-core/lib/cjs/puppeteer/common/QueryHandler.js:172:95) at async CdpFrame.waitForSelector (/Users/Documents/node_modules/auto-linkedin/node_modules/puppeteer-core/lib/cjs/puppeteer/api/Frame.js:522:21) at async CdpPage.waitForSelector (/Users/Documents/node_modules/auto-linkedin/node_modules/puppeteer-core/lib/cjs/puppeteer/api/Page.js:1305:20) at async LinkedIn.extractLinkedinProfilesFromSearch (/Users/Documents/node_modules/auto-linkedin/src/controllers/linkedin.js:206:5) at async LinkedIn.searchPeople (/Users/Documents/node_modules/auto-linkedin/src/controllers/linkedin.js:185:24)

Ranork commented 3 weeks ago

It can be a network problem, does the problem persist?

dileepmaurya87 commented 3 weeks ago

Yes

dileepmaurya87 commented 3 weeks ago

Can you please help for above problem I tried your electron app to unable to get results it gets struck

Ranork commented 3 weeks ago

Make the browser headless: false again and see if search page comes correctly. Looks like https://github.com/Ranork/Auto-Linkedin/blob/main/src/controllers/linkedin.js#L206 gives error in this line.