feat: Facebook page data collection via Apify scraper

- enrich-channels: add Facebook Pages Scraper (apify~facebook-pages-scraper)
- Collects: pageName, followers, likes, categories, email, phone, website, intro, rating
- transformReport: merge Facebook data into facebookAudit.pages[] (auto-shows section)
- Frontend: pass facebookHandle through enrichment pipeline
- EnrichChannelsRequest: add facebookHandle parameter

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Haewon KamandClaude Opus 4.6 committed 2026-04-03 16:16:37 +09:00
1 parent ad625e08ee
commit a7d8aeeddc
5 files changed
+85 -2

No files matched your search

+40 -2
View File
@@ -16,6 +16,7 @@ interface EnrichRequest {
instagramHandle?: string;
instagramHandles?: string[];
youtubeChannelId?: string;
facebookHandle?: string;
address?: string;
}
@@ -48,7 +49,7 @@ Deno.serve(async (req) => {
}
try {
const { reportId, clinicName, instagramHandle, instagramHandles, youtubeChannelId, address } =
const { reportId, clinicName, instagramHandle, instagramHandles, youtubeChannelId, facebookHandle, address } =
(await req.json()) as EnrichRequest;
// Build list of IG handles to try: explicit array > single handle > empty
@@ -327,7 +328,44 @@ Deno.serve(async (req) => {
}
}
// 5. YouTube Channel (using YouTube Data API v3)
// 5. Facebook Page (using Apify)
if (facebookHandle) {
tasks.push(
(async () => {
// Normalize: strip URL parts to get page name, then build full URL
let fbUrl = facebookHandle;
if (!fbUrl.startsWith("http")) {
fbUrl = fbUrl.replace(/^@/, "");
fbUrl = `https://www.facebook.com/${fbUrl}`;
}
const items = await runApifyActor(
"apify~facebook-pages-scraper",
{ startUrls: [{ url: fbUrl }] },
APIFY_TOKEN
);
const page = (items as Record<string, unknown>[])[0];
if (page && page.title) {
enrichment.facebook = {
pageName: page.title,
pageUrl: page.pageUrl || fbUrl,
followers: page.followers,
likes: page.likes,
categories: page.categories,
email: page.email,
phone: page.phone,
website: page.website,
address: page.address,
intro: page.intro,
rating: page.rating,
profilePictureUrl: page.profilePictureUrl,
};
}
})()
);
}
// 6. YouTube Channel (using YouTube Data API v3)
if (youtubeChannelId) {
const YOUTUBE_API_KEY = Deno.env.get("YOUTUBE_API_KEY");
if (YOUTUBE_API_KEY) {