Auto-deploy: 2026-06-05 22:51:59
This commit is contained in:
@@ -43,43 +43,55 @@
|
||||
summary: ''
|
||||
};
|
||||
|
||||
// 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'));
|
||||
try {
|
||||
// 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 nameEl = cardEl.querySelector('.entity-result__title-text, .search-result__title, span[dir="ltr"]');
|
||||
if (nameEl) data.name = nameEl.innerText.trim().split('\n')[0];
|
||||
}
|
||||
if (profileLinks.length > 0) {
|
||||
data.name = profileLinks[0].innerText.trim().split('\n')[0];
|
||||
} else {
|
||||
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, [class*="subtitle"], .linked-area');
|
||||
if (headlineEl) {
|
||||
data.headline = headlineEl.innerText.trim();
|
||||
}
|
||||
// 2. Extract Headline
|
||||
const headlineEl = cardEl.querySelector('.entity-result__primary-subtitle, [class*="subtitle"], .linked-area');
|
||||
if (headlineEl) {
|
||||
data.headline = headlineEl.innerText.trim();
|
||||
}
|
||||
|
||||
// 3. Extract Location
|
||||
const locationEl = cardEl.querySelector('.entity-result__secondary-subtitle, .search-result__info');
|
||||
if (locationEl) {
|
||||
data.location = locationEl.innerText.trim();
|
||||
}
|
||||
// 3. Extract Location
|
||||
const locationEl = cardEl.querySelector('.entity-result__secondary-subtitle, .search-result__info');
|
||||
if (locationEl) {
|
||||
data.location = locationEl.innerText.trim();
|
||||
}
|
||||
|
||||
// 4. Extract Summary
|
||||
const summaryEl = cardEl.querySelector('.entity-result__summary, .search-result__snippets');
|
||||
if (summaryEl) {
|
||||
data.summary = summaryEl.innerText.trim();
|
||||
}
|
||||
// 4. Extract Summary
|
||||
const summaryEl = cardEl.querySelector('.entity-result__summary, .search-result__snippets');
|
||||
if (summaryEl) {
|
||||
data.summary = summaryEl.innerText.trim();
|
||||
}
|
||||
|
||||
// Clean up
|
||||
if (data.name) 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];
|
||||
// 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];
|
||||
}
|
||||
|
||||
// Final fallback to avoid empty name
|
||||
if (!data.name) {
|
||||
data.name = 'مستثمر محتمل';
|
||||
data.summary = cardEl.innerText ? cardEl.innerText.substring(0, 300) : '';
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('[LJA] Extraction failed', e);
|
||||
data.name = 'مستثمر محتمل';
|
||||
data.summary = cardEl.innerText ? cardEl.innerText.substring(0, 300) : '';
|
||||
}
|
||||
|
||||
return data;
|
||||
@@ -197,7 +209,8 @@
|
||||
|
||||
const data = extractPersonData(cardEl);
|
||||
if (!data.name && !data.headline) {
|
||||
alert('Could not extract person details.');
|
||||
console.error('[LJA] Could not extract details, skipping.');
|
||||
btnEl.innerHTML = '❌ Extraction Failed';
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user