Auto-deploy: 2026-06-05 22:45:17
This commit is contained in:
@@ -43,19 +43,19 @@
|
||||
summary: ''
|
||||
};
|
||||
|
||||
// 1. Extract Name (Usually inside a link with /in/)
|
||||
const nameEl = cardEl.querySelector('.entity-result__title-text, .search-result__title, span[dir="ltr"]');
|
||||
if (nameEl) {
|
||||
data.name = nameEl.innerText.trim().split('\n')[0];
|
||||
// 1. Extract Name (Prioritize links over generic spans)
|
||||
const profileLinks = Array.from(cardEl.querySelectorAll('a[href*="/in/"]'))
|
||||
.filter(a => a.innerText.trim().length > 2 && !a.innerText.includes('LinkedIn'));
|
||||
|
||||
if (profileLinks.length > 0) {
|
||||
data.name = profileLinks[0].innerText.trim().split('\n')[0];
|
||||
} else {
|
||||
const profileLinks = Array.from(cardEl.querySelectorAll('a[href*="/in/"]')).filter(a => a.innerText.trim().length > 0);
|
||||
if (profileLinks.length > 0) {
|
||||
data.name = profileLinks[0].innerText.trim().split('\n')[0];
|
||||
}
|
||||
const nameEl = cardEl.querySelector('.entity-result__title-text, .search-result__title, span[dir="ltr"]');
|
||||
if (nameEl) data.name = nameEl.innerText.trim().split('\n')[0];
|
||||
}
|
||||
|
||||
// 2. Extract Headline
|
||||
const headlineEl = cardEl.querySelector('.entity-result__primary-subtitle, .search-result__truncate, .linked-area');
|
||||
const headlineEl = cardEl.querySelector('.entity-result__primary-subtitle, [class*="subtitle"], .linked-area');
|
||||
if (headlineEl) {
|
||||
data.headline = headlineEl.innerText.trim();
|
||||
}
|
||||
@@ -72,8 +72,15 @@
|
||||
data.summary = summaryEl.innerText.trim();
|
||||
}
|
||||
|
||||
// Clean up "View Profile" texts
|
||||
data.name = data.name.replace(/View .* profile/gi, '').trim();
|
||||
// Clean up
|
||||
if (data.name) data.name = data.name.replace(/View .* profile/gi, '').trim();
|
||||
|
||||
// Ultimate Fallback: just take the first lines of text in the card
|
||||
if (!data.name || data.name.length < 2) {
|
||||
const lines = cardEl.innerText.split('\n').map(s => s.trim()).filter(s => s.length > 2 && !s.includes('Degree connection'));
|
||||
if (lines.length > 0) data.name = lines[0];
|
||||
if (lines.length > 1 && !data.headline) data.headline = lines[1];
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user