Auto-deploy: 2026-06-05 22:51:59
This commit is contained in:
@@ -43,43 +43,55 @@
|
|||||||
summary: ''
|
summary: ''
|
||||||
};
|
};
|
||||||
|
|
||||||
// 1. Extract Name (Prioritize links over generic spans)
|
try {
|
||||||
const profileLinks = Array.from(cardEl.querySelectorAll('a[href*="/in/"]'))
|
// 1. Extract Name (Prioritize links over generic spans)
|
||||||
.filter(a => a.innerText.trim().length > 2 && !a.innerText.includes('LinkedIn'));
|
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];
|
if (profileLinks.length > 0) {
|
||||||
} else {
|
data.name = profileLinks[0].innerText.trim().split('\n')[0];
|
||||||
const nameEl = cardEl.querySelector('.entity-result__title-text, .search-result__title, span[dir="ltr"]');
|
} else {
|
||||||
if (nameEl) data.name = nameEl.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
|
// 2. Extract Headline
|
||||||
const headlineEl = cardEl.querySelector('.entity-result__primary-subtitle, [class*="subtitle"], .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();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Extract Location
|
// 3. Extract Location
|
||||||
const locationEl = cardEl.querySelector('.entity-result__secondary-subtitle, .search-result__info');
|
const locationEl = cardEl.querySelector('.entity-result__secondary-subtitle, .search-result__info');
|
||||||
if (locationEl) {
|
if (locationEl) {
|
||||||
data.location = locationEl.innerText.trim();
|
data.location = locationEl.innerText.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. Extract Summary
|
// 4. Extract Summary
|
||||||
const summaryEl = cardEl.querySelector('.entity-result__summary, .search-result__snippets');
|
const summaryEl = cardEl.querySelector('.entity-result__summary, .search-result__snippets');
|
||||||
if (summaryEl) {
|
if (summaryEl) {
|
||||||
data.summary = summaryEl.innerText.trim();
|
data.summary = summaryEl.innerText.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clean up
|
// Clean up
|
||||||
if (data.name) 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
|
// Ultimate Fallback: just take the first lines of text in the card
|
||||||
if (!data.name || data.name.length < 2) {
|
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'));
|
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 > 0) data.name = lines[0];
|
||||||
if (lines.length > 1 && !data.headline) data.headline = lines[1];
|
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;
|
return data;
|
||||||
@@ -197,7 +209,8 @@
|
|||||||
|
|
||||||
const data = extractPersonData(cardEl);
|
const data = extractPersonData(cardEl);
|
||||||
if (!data.name && !data.headline) {
|
if (!data.name && !data.headline) {
|
||||||
alert('Could not extract person details.');
|
console.error('[LJA] Could not extract details, skipping.');
|
||||||
|
btnEl.innerHTML = '❌ Extraction Failed';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user