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