Spaces:
Sleeping
Sleeping
| /** | |
| * Threads Scraper | |
| * Uses Apify Instagram Scraper (Threads is part of Meta) | |
| */ | |
| import { runApifyActor, ACTOR_IDS, type ScrapingResult } from './apify'; | |
| import { extractPostId } from './detector'; | |
| /** | |
| * Scrape Threads post by URL | |
| */ | |
| export async function scrapeThreads(url: string): Promise<ScrapingResult> { | |
| try { | |
| const postId = extractPostId(url); | |
| if (!postId) { | |
| return { | |
| success: false, | |
| error: 'Could not extract post ID from Threads URL', | |
| }; | |
| } | |
| // Threads posts can be accessed via Instagram's API structure | |
| const result = await runApifyActor(ACTOR_IDS.threads, { | |
| direct_urls: [url], | |
| results_limit: 1, | |
| }); | |
| return { | |
| ...result, | |
| title: 'Threads Post', | |
| }; | |
| } catch (error) { | |
| console.error('[threads scraper] failed:', error); | |
| return { | |
| success: false, | |
| error: error instanceof Error ? error.message : 'Failed to scrape Threads', | |
| }; | |
| } | |
| } | |