@mvegter/scrapedin 1.2.0 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mvegter/scrapedin",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "linkedin scraper updated for 2025+ website",
5
5
  "keywords": [
6
6
  "linkedin",
@@ -8,8 +8,12 @@
8
8
  "crawler"
9
9
  ],
10
10
  "main": "src/scrapedin.js",
11
+ "files": [
12
+ "src"
13
+ ],
11
14
  "scripts": {
12
- "lint": "standard --fix 'src/*.js'"
15
+ "lint": "standard --fix 'src/*.js'",
16
+ "test": "node --test test/"
13
17
  },
14
18
  "repository": {
15
19
  "type": "git",
@@ -21,14 +25,14 @@
21
25
  "author": "Wagner Leonardi <leonardiwagner@gmail.com>",
22
26
  "license": "Apache-2.0",
23
27
  "dependencies": {
24
- "puppeteer": "24.36.0",
25
- "winston": "3.7.2"
28
+ "puppeteer": "25.19.0",
29
+ "winston": "3.19.0"
26
30
  },
27
31
  "devDependencies": {
28
- "standard": "17.0.0"
32
+ "standard": "17.1.2"
29
33
  },
30
34
  "engines": {
31
- "node": ">= 16.0.0"
35
+ "node": ">= 22.12.0"
32
36
  },
33
37
  "homepage": "https://github.com/linkedtales/scrapedin#readme"
34
38
  }
@@ -1,5 +1,5 @@
1
1
  const openPage = require('../openPage')
2
- const scrollToPageBottom = require('./scrollToPageBottom')
2
+ const scrollProfileCardsIntoView = require('./scrollProfileCardsIntoView')
3
3
  const seeMoreButtons = require('./seeMoreButtons')
4
4
  const contactInfo = require('./contactInfo')
5
5
  const cleanProfileData = require('./cleanProfileData')
@@ -9,6 +9,8 @@ const logger = require('../logger')(__filename)
9
9
  const extractProfileData = async (page) => {
10
10
  return page.evaluate(() => {
11
11
  const txt = (el) => el ? (el.textContent || '').trim() : ''
12
+ // innerText keeps the <br> paragraph breaks LinkedIn uses in descriptions
13
+ const multiline = (el) => el ? (el.innerText || '').trim() : ''
12
14
 
13
15
  const findSection = (headingText) => {
14
16
  const sections = document.querySelectorAll('section')
@@ -28,17 +30,11 @@ const extractProfileData = async (page) => {
28
30
  return [...content.querySelectorAll(':scope > div')].filter(d => d.querySelector('p'))
29
31
  }
30
32
 
31
- // Profile top card
32
- const sections = document.querySelectorAll('section')
33
- let topSection = null
34
- for (const s of sections) {
35
- const h2 = s.querySelector('h2')
36
- if (h2 && ['0 notifications', 'Suggested for you', 'Analytics', 'Activity'].includes(h2.textContent.trim())) continue
37
- if (s.textContent.trim().length > 200) { topSection = s; break }
38
- }
39
-
40
33
  const nameH1 = document.querySelector('h1')
41
34
  const profileName = nameH1 ? txt(nameH1) : document.title.replace(' | LinkedIn', '').trim()
35
+
36
+ // Profile top card
37
+ const topSection = [...document.querySelectorAll('section')].find(s => txt(s.querySelector('h2')) === profileName)
42
38
  let headline = ''
43
39
  let location = ''
44
40
  if (topSection) {
@@ -92,28 +88,26 @@ const extractProfileData = async (page) => {
92
88
  link: companyUrl,
93
89
  url: companyUrl,
94
90
  location: '',
95
- description: descEl ? txt(descEl) : '',
91
+ description: multiline(descEl),
96
92
  date: dateRange,
97
93
  date1: dateParts[0] ? dateParts[0].trim() : '',
98
94
  date2: dateParts[1] ? dateParts[1].trim() : ''
99
95
  })
100
96
  })
101
97
  } else {
98
+ // Single-role entry lines before the description: title, "company · employment type", "dates · duration",
99
+ // a "Present" badge on current roles, optional location. The skills line follows the description.
102
100
  const descEl = group.querySelector('[data-testid="expandable-text-box"]')
103
- let dateStr = ''
104
- for (let i = 1; i < allP.length; i++) {
105
- const t = txt(allP[i])
106
- if (t.includes('\u00B7') || /\d{4}/.test(t.split(' ')[0])) { dateStr = t; break }
107
- }
108
- const dateRange = dateStr.split('\u00B7')[0].trim()
101
+ const headerPs = allP.filter(p => !descEl || p.compareDocumentPosition(descEl) & window.Node.DOCUMENT_POSITION_FOLLOWING)
102
+ const dateRange = txt(headerPs[2]).split('\u00B7')[0].trim()
109
103
  const dateParts = dateRange.split(' - ')
110
104
  positions.push({
111
- title: txt(allP[3]) || txt(allP[1]),
112
- companyName,
105
+ title: txt(headerPs[0]),
106
+ companyName: txt(headerPs[1]).split('\u00B7')[0].trim(),
113
107
  link: companyUrl,
114
108
  url: companyUrl,
115
- location: txt(allP[2]) || '',
116
- description: descEl ? txt(descEl) : '',
109
+ location: txt(headerPs.slice(3).find(p => txt(p) !== dateParts[1])),
110
+ description: multiline(descEl),
117
111
  date: dateRange,
118
112
  date1: dateParts[0] ? dateParts[0].trim() : '',
119
113
  date2: dateParts[1] ? dateParts[1].trim() : ''
@@ -179,12 +173,13 @@ const extractProfileData = async (page) => {
179
173
  projDivs.forEach(div => {
180
174
  const ps = [...div.querySelectorAll('p')].filter(p => txt(p).length > 0)
181
175
  if (ps.length === 0) return
182
- const descEl = div.querySelector('[data-testid="expandable-text-box"]')
176
+ // The project name is wrapped in an expandable text box too
177
+ const descEl = [...div.querySelectorAll('[data-testid="expandable-text-box"]')].find(box => !box.contains(ps[0]) && !ps[0].contains(box))
183
178
  const link = div.querySelector('a[href*="http"]')
184
179
  projects.push({
185
180
  name: txt(ps[0]),
186
181
  date: txt(ps[1]) || '',
187
- description: descEl ? txt(descEl) : '',
182
+ description: multiline(descEl),
188
183
  link: link ? link.getAttribute('href') : ''
189
184
  })
190
185
  })
@@ -216,7 +211,7 @@ const extractProfileData = async (page) => {
216
211
  })
217
212
  }
218
213
 
219
- module.exports = async (browser, cookies, url, waitTimeToScrapMs = 500, hasToGetContactInfo = false, puppeteerAuthenticate = undefined) => {
214
+ const scrapeProfile = async (browser, cookies, url, waitTimeToScrapMs = 500, hasToGetContactInfo = false, puppeteerAuthenticate = undefined) => {
220
215
  logger.info(`starting scraping url: ${url}`)
221
216
 
222
217
  const page = await openPage({ browser, cookies, url, puppeteerAuthenticate })
@@ -248,13 +243,13 @@ module.exports = async (browser, cookies, url, waitTimeToScrapMs = 500, hasToGet
248
243
  })
249
244
 
250
245
  logger.info('scrolling page to the bottom')
251
- await scrollToPageBottom(page)
246
+ await scrollProfileCardsIntoView(page)
252
247
 
253
248
  // Wait for lazy-loaded sections to render after scrolling
254
249
  await new Promise((resolve) => { setTimeout(resolve, 2000) })
255
250
 
256
251
  // Scroll again in case new content was loaded
257
- await scrollToPageBottom(page)
252
+ await scrollProfileCardsIntoView(page)
258
253
  await new Promise((resolve) => { setTimeout(resolve, 1000) })
259
254
 
260
255
  await seeMoreButtons.clickAll(page)
@@ -274,3 +269,6 @@ module.exports = async (browser, cookies, url, waitTimeToScrapMs = 500, hasToGet
274
269
  const cleanedProfile = cleanProfileData(rawProfile)
275
270
  return cleanedProfile
276
271
  }
272
+
273
+ module.exports = scrapeProfile
274
+ module.exports.extractProfileData = extractProfileData
@@ -0,0 +1,18 @@
1
+ const logger = require('../logger')(__filename)
2
+
3
+ const TIMEOUT_AFTER_SCROLL = 1200
4
+
5
+ // The profile scrolls inside an inner container, so scrolling the window never triggers the lazily rendered cards.
6
+ module.exports = async (page) => {
7
+ const cardIds = await page.evaluate(() => [...document.querySelectorAll('[id^="profileCards"]')].map(e => e.id))
8
+ if (cardIds.length === 0) {
9
+ logger.warn('no profile cards found')
10
+ return
11
+ }
12
+
13
+ for (const id of cardIds) {
14
+ await page.evaluate((id) => document.getElementById(id).scrollIntoView({ block: 'center' }), id)
15
+ await new Promise(resolve => setTimeout(resolve, TIMEOUT_AFTER_SCROLL))
16
+ }
17
+ logger.info(`scrolled ${cardIds.length} profile cards into view`)
18
+ }
@@ -3,8 +3,8 @@ const logger = require('../logger')(__filename)
3
3
  const clickAll = async (page) => {
4
4
  const clicked = await page.evaluate(() => {
5
5
  let count = 0
6
- // Only click expandable text buttons (inline expand, not navigation)
7
- const expandButtons = document.querySelectorAll('[data-testid="expandable-text-button"]')
6
+ // Only inline expand buttons inside profile cards: the same button on an activity post navigates to that post
7
+ const expandButtons = document.querySelectorAll('[id^="profileCards"] [data-testid="expandable-text-button"]')
8
8
  expandButtons.forEach(btn => { btn.click(); count++ })
9
9
  return count
10
10
  })
@@ -1,11 +0,0 @@
1
- # To get started with Dependabot version updates, you'll need to specify which
2
- # package ecosystems to update and where the package manifests are located.
3
- # Please see the documentation for all configuration options:
4
- # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5
-
6
- version: 2
7
- updates:
8
- - package-ecosystem: "npm" # See documentation for possible values
9
- directory: "/" # Location of package manifests
10
- schedule:
11
- interval: "daily"
package/logo.png DELETED
Binary file
@@ -1,186 +0,0 @@
1
- const template = {
2
- profile: {
3
- selector: '.scaffold-layout__main',
4
- fields: {
5
- name: '.text-heading-xlarge',
6
- headline: '.text-body-medium',
7
- location: '.text-body-small.inline.t-black--light.break-words',
8
- connections: '.t-bold',
9
- imageurl: {
10
- selector: 'img.pv-top-card-profile-picture__image',
11
- attribute: 'src'
12
- }
13
- }
14
- },
15
- about: {
16
- selector: '#about ~ .display-flex .inline-show-more-text',
17
- fields: {
18
- text: 'span[aria-hidden="true"]'
19
- }
20
- },
21
- positions: {
22
- selector: '#experience ~ .pvs-list__outer-container .pvs-list > li.pvs-list__paged-list-item',
23
- fields: {
24
- title: '.mr1.hoverable-link-text.t-bold > span',
25
- link: {
26
- selector: 'a.optional-action-target-wrapper',
27
- attribute: 'href'
28
- },
29
- url: {
30
- selector: 'a.optional-action-target-wrapper',
31
- attribute: 'href'
32
- },
33
- companyName: '.t-14.t-normal > span',
34
- location: '.t-14.t-normal.t-black--light > span',
35
- description: '.pvs-list__outer-container .inline-show-more-text span[aria-hidden="true"]',
36
- date1: '.pvs-entity__caption-wrapper',
37
- date2: '.pvs-entity__caption-wrapper',
38
- roles: {
39
- selector: '.pvs-entity__sub-components li.pvs-list__paged-list-item',
40
- hasChildrenFields: true,
41
- fields: {
42
- title: '.mr1.hoverable-link-text.t-bold > span',
43
- description: '.inline-show-more-text span[aria-hidden="true"]',
44
- date: '.pvs-entity__caption-wrapper',
45
- location: '.t-14.t-normal.t-black--light > span'
46
- }
47
- }
48
- }
49
- },
50
- educations: {
51
- selector: '#education ~ .pvs-list__outer-container .pvs-list > li.pvs-list__paged-list-item',
52
- fields: {
53
- title: '.hoverable-link-text.t-bold > span',
54
- degree: '.t-14.t-normal > span',
55
- url: {
56
- selector: 'a',
57
- attribute: 'href'
58
- },
59
- fieldOfStudy: '.t-14.t-normal > span',
60
- date1: '.pvs-entity__caption-wrapper',
61
- date2: '.pvs-entity__caption-wrapper',
62
- description: '.inline-show-more-text span[aria-hidden="true"]'
63
- }
64
- },
65
- skills: {
66
- selector: '#skills ~ .pvs-list__outer-container .pvs-list > li.pvs-list__paged-list-item',
67
- fields: {
68
- title: '.mr1.hoverable-link-text.t-bold > span',
69
- count: '.t-14.t-normal.t-black--light > span'
70
- }
71
- },
72
- recommendationsCount: {
73
- selector: '#recommendations ~ .pvs-list__outer-container',
74
- fields: {
75
- received: '.artdeco-tab:nth-child(1)',
76
- given: '.artdeco-tab:nth-child(2)'
77
- }
78
- },
79
- recommendationsReceived: {
80
- selector: '#recommendations ~ .pvs-list__outer-container .pvs-list > li.pvs-list__paged-list-item',
81
- fields: {
82
- user: {
83
- selector: 'a',
84
- attribute: 'href'
85
- },
86
- text: '.inline-show-more-text span[aria-hidden="true"]',
87
- profileImage: {
88
- selector: 'img',
89
- attribute: 'src'
90
- },
91
- name: {
92
- selector: '.t-bold > span'
93
- },
94
- userDescription: {
95
- selector: '.t-14.t-normal > span'
96
- }
97
- }
98
- },
99
- recommendationsGiven: {
100
- selector: '#recommendations ~ .pvs-list__outer-container .pvs-list > li.pvs-list__paged-list-item',
101
- fields: {
102
- user: {
103
- selector: 'a',
104
- attribute: 'href'
105
- },
106
- text: '.inline-show-more-text span[aria-hidden="true"]',
107
- profileImage: {
108
- selector: 'img',
109
- attribute: 'src'
110
- },
111
- name: {
112
- selector: '.t-bold > span'
113
- },
114
- userDescription: {
115
- selector: '.t-14.t-normal > span'
116
- }
117
- }
118
- },
119
- accomplishments: {
120
- selector: '#honors_and_awards ~ .pvs-list__outer-container .pvs-list > li.pvs-list__paged-list-item',
121
- fields: {
122
- count: '.t-14.t-normal.t-black--light > span',
123
- title: '.mr1.hoverable-link-text.t-bold > span',
124
- items: {
125
- selector: '.pvs-list__outer-container li',
126
- isMultipleFields: true
127
- }
128
- }
129
- },
130
- peopleAlsoViewed: {
131
- selector: '.pv-browsemap-section li',
132
- fields: {
133
- user: {
134
- selector: 'a',
135
- attribute: 'href'
136
- },
137
- text: '.t-14.t-normal',
138
- profileImage: {
139
- selector: 'img',
140
- attribute: 'src'
141
- },
142
- name: {
143
- selector: '.t-bold'
144
- }
145
- }
146
- },
147
- volunteerExperience: {
148
- selector: '#volunteering_experience ~ .pvs-list__outer-container .pvs-list > li.pvs-list__paged-list-item',
149
- fields: {
150
- title: '.mr1.hoverable-link-text.t-bold > span',
151
- experience: '.t-14.t-normal > span',
152
- location: '.t-14.t-normal.t-black--light > span',
153
- description: '.inline-show-more-text span[aria-hidden="true"]',
154
- date1: '.pvs-entity__caption-wrapper',
155
- date2: '.pvs-entity__caption-wrapper'
156
- }
157
- },
158
- courses: {
159
- selector: '#courses ~ .pvs-list__outer-container .pvs-list > li.pvs-list__paged-list-item',
160
- fields: {
161
- name: '.mr1.hoverable-link-text.t-bold > span',
162
- year: '.t-14.t-normal > span'
163
- }
164
- },
165
- languages: {
166
- selector: '#languages ~ .pvs-list__outer-container .pvs-list > li.pvs-list__paged-list-item',
167
- fields: {
168
- name: '.mr1.t-bold > span',
169
- proficiency: '.t-14.t-normal.t-black--light > span'
170
- }
171
- },
172
- projects: {
173
- selector: '#projects ~ .pvs-list__outer-container .pvs-list > li.pvs-list__paged-list-item',
174
- fields: {
175
- name: '.mr1.hoverable-link-text.t-bold > span',
176
- date: '.pvs-entity__caption-wrapper',
177
- description: '.inline-show-more-text span[aria-hidden="true"]',
178
- link: {
179
- selector: 'a',
180
- attribute: 'href'
181
- }
182
- }
183
- }
184
- }
185
-
186
- module.exports = template
@@ -1,11 +0,0 @@
1
- const scrapSection = require('../scrapSection')
2
- const template = require('./profileScraperTemplate')
3
-
4
- const scrapAccomplishmentPanel = async (page, section) => {
5
- if (!template[section]) {
6
- return []
7
- }
8
- return scrapSection(page, template[section])
9
- }
10
-
11
- module.exports = scrapAccomplishmentPanel
@@ -1,23 +0,0 @@
1
- const logger = require('../logger')(__filename)
2
-
3
- module.exports = async (page) => {
4
- const MAX_TIMES_TO_SCROLL = 25
5
- const TIMEOUT_BETWEEN_SCROLLS = 500
6
-
7
- for (let i = 0; i < MAX_TIMES_TO_SCROLL; i++) {
8
- await page.evaluate(() => window.scrollBy(0, window.innerHeight))
9
-
10
- const hasReachedEnd = await page.evaluate(() => {
11
- return (window.innerHeight + window.scrollY) >= (document.body.scrollHeight - 200)
12
- })
13
-
14
- if (hasReachedEnd) {
15
- return
16
- }
17
-
18
- await new Promise(resolve => setTimeout(resolve, TIMEOUT_BETWEEN_SCROLLS))
19
- logger.info(`scrolling to page bottom (${i + 1})`)
20
- }
21
-
22
- logger.warn('page bottom not found')
23
- }