fix: keep unverified Instagram handles as candidates for collection

Instagram HEAD requests often fail (rate limiting, blocking) causing
valid handles to be dropped. Now all discovered handles are kept
(verified or not) and Apify attempts collection on all of them.
Apify's own scraper validates existence more reliably than HEAD requests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
claude/bold-hawking
Haewon Kam 2026-04-04 01:38:12 +09:00
parent 087f65eec1
commit 1fb1de8303
2 changed files with 6 additions and 6 deletions

View File

@ -190,10 +190,10 @@ export async function verifyAllHandles(
tiktok: null, tiktok: null,
}; };
// Instagram — verify each candidate // Instagram — verify each candidate, keep unverified as fallback
for (const handle of candidates.instagram.slice(0, 5)) { for (const handle of candidates.instagram.slice(0, 5)) {
tasks.push( tasks.push(
verifyInstagram(handle).then(v => { if (v.verified) result.instagram.push(v); }) verifyInstagram(handle).then(v => { result.instagram.push(v); })
); );
} }

View File

@ -72,12 +72,12 @@ Deno.serve(async (req) => {
const analysisData: Record<string, unknown> = {}; const analysisData: Record<string, unknown> = {};
const tasks: Promise<void>[] = []; const tasks: Promise<void>[] = [];
// ─── 1. Instagram (multi-account) ─── // ─── 1. Instagram (multi-account) — try ALL candidates including unverified ───
const igVerified = (verified.instagram || []).filter((v: Record<string, unknown>) => v.verified && v.handle); const igCandidates = (verified.instagram || []).filter((v: Record<string, unknown>) => v.handle);
if (APIFY_TOKEN && igVerified.length > 0) { if (APIFY_TOKEN && igCandidates.length > 0) {
tasks.push((async () => { tasks.push((async () => {
const accounts: Record<string, unknown>[] = []; const accounts: Record<string, unknown>[] = [];
for (const ig of igVerified) { for (const ig of igCandidates) {
const items = await runApifyActor("apify~instagram-profile-scraper", { usernames: [ig.handle], resultsLimit: 12 }, APIFY_TOKEN); const items = await runApifyActor("apify~instagram-profile-scraper", { usernames: [ig.handle], resultsLimit: 12 }, APIFY_TOKEN);
const profile = (items as Record<string, unknown>[])[0]; const profile = (items as Record<string, unknown>[])[0];
if (profile && !profile.error) { if (profile && !profile.error) {