18 lines
539 B
TypeScript
18 lines
539 B
TypeScript
import { NextRequest, NextResponse } from 'next/server'
|
|
import { prisma } from '@/lib/prisma'
|
|
import { scrapeDouyin } from '.';
|
|
|
|
async function handleDouyinScrape(req: NextRequest) {
|
|
const { searchParams } = new URL(req.url);
|
|
const videoUrl = searchParams.get('url');
|
|
if (!videoUrl) {
|
|
return NextResponse.json({ error: '缺少视频URL' }, { status: 400 });
|
|
}
|
|
|
|
// 调用爬虫函数
|
|
const result = await scrapeDouyin(videoUrl);
|
|
return NextResponse.json(result);
|
|
}
|
|
|
|
export const GET = handleDouyinScrape
|