本指南详细说明了如何调用后端提供的 Pinterest 数据采集接口。
Base URL: http://<your-server-ip>:3000/api/pinterest
根据关键词搜索 Pinterest 博主。
注意: 后端会自动将关键词转换为 Pinterest 搜索链接 (https://www.pinterest.com/search/users/?q=...) 进行采集。
/searchGETkeyword (必填): 搜索关键词,例如 fashioncountry (选填): 国家代码,默认为 US(目前该参数主要用于记录,实际搜索结果取决于 Dataset 采集时的 IP 策略)请求示例:
// GET /api/pinterest/search?keyword=fashion
fetch('http://localhost:3000/api/pinterest/search?keyword=fashion')
.then(res => res.json())
.then(data => console.log(data));
响应示例:
{
"success": true,
"data": [
{
"url": "https://www.pinterest.com/example_user/",
"name": "Example User",
"follower_count": 12345,
"description": "Fashion blogger...",
// ... 其他博主信息
}
],
"timestamp": "2024-02-14T..."
}
获取指定博主的帖子/视频列表。
/users/postsGETurl (必填): 博主的 Pinterest 个人主页链接count (选填): 获取数量,默认为 20请求示例:
// GET /api/pinterest/users/posts?url=https://www.pinterest.com/example_user/&count=10
const profileUrl = encodeURIComponent('https://www.pinterest.com/example_user/');
fetch(`http://localhost:3000/api/pinterest/users/posts?url=${profileUrl}&count=10`)
.then(res => res.json())
.then(data => console.log(data));
响应示例:
{
"success": true,
"data": [
{
"url": "https://www.pinterest.com/pin/123456789/",
"title": "Post Title",
"image_video_url": "...",
// ... 其他帖子信息
}
],
"timestamp": "..."
}
获取指定帖子的详情及评论。
/posts/commentsGETurl (必填): 帖子的链接请求示例:
// GET /api/pinterest/posts/comments?url=https://www.pinterest.com/pin/123456789/
const postUrl = encodeURIComponent('https://www.pinterest.com/pin/123456789/');
fetch(`http://localhost:3000/api/pinterest/posts/comments?url=${postUrl}`)
.then(res => res.json())
.then(data => console.log(data));
响应示例:
{
"success": true,
"data": {
"post_id": "123456789",
"title": "Post Title",
"comments_num": 10,
"comments": [
{
"comment_id": "...",
"text": "Great post!",
"author_name": "User A",
"date": "...",
"likes": 5
}
]
},
"timestamp": "..."
}
encodeURIComponent 进行编码。