♬ TikTok
社交媒体爬虫 API 允许你从TikTok抓取信息。
以下由 API 驱动的目标可用。你应该更喜欢使用这些,它们平均速度更快并且提供更多参数:
tiktok_api_profile
tiktok_api_hashtag
以下旧目标也可用。仅当 API 目标不满足你的需求时(例如,如果你需要异步请求),你才应该使用它们:
tiktok_profile
tiktok_hashtag
tiktok_post
API 目标
TikTok API 目标目前仅支持同步请求。
TikTok 资料
POST https://scraper-api.smartdaili-china.com/v2/scrape
有效载荷类型: JSON
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
query | string | ✅ | TikTok 用户名 | gordonramsayofficial |
target | string | ✅ | 目标 | tiktok_api_profile |
count | number | 要返回的结果数。(至少1 。最多35 。默认为10 ) | 20 | |
timestamp | number | 给定时间戳 日期,将从该日期开始返回最后的计数 条目。时间戳必须采用秒格式(通常为 10 位数字) | 1681938000 (2023 Apr 20) | |
geo | string | 地理位置 (请注意,此目标不适用于地理位置 美国 ) | United Kingdom | |
locale | string | 语言环境 | en-GB |
提取更多配置文件结果
抓取TikTok个人资料时,每个请求的视频上限为 35 个。如果你希望提取更多结果,请复制发出请求后获得的最后结果的时间戳
,并使用作为参数传递的时间戳
值发出新请求。这允许你对个人资料视频进行分页。
例如,要获取前 35 个结果,应使用以下有效负载:
{
"target": "tiktok_api_profile",
"query": "gordonramsayofficial",
"count": 35
}
每个返回的结果都会有一个createTime
字段。最后一个需要复制。
{
"data": {
"content": {
"itemList": [
// first 14 entries
...
// last item
{
// other fields
...
"createTime": 1676266498
}
]
}
}
}
为了获取下一页,应使用以下有效负载:
{
"target": "tiktok_api_profile",
"query": "gordonramsayofficial",
"count": 35,
"timestamp": 1676266498 // added
}
TikTok 标签
POST https://scraper-api.smartdaili-china.com/v2/scrape
有效载荷类型: JSON
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
query | string | ✅ | 标签搜索查询 | tasty |
target | string | ✅ | 目标 | tiktok_api_hashtag |
count | number | 要返回的结果数。(至少1 。最多35 。默认为10 ) | 15 | |
cursor | number | 用于指示结果应如何偏移的数字。默认为 0(获取你将在页面顶部看到的结果 | 10 | |
geo | string | 地理位置 | United States | |
locale | string | 语言环境 | en-GB |
提取更多主题标签结果
为提取更多主题标签结果,请增加count
参数。
{
"target": "tiktok_api_hashtag",
"query": "tasty",
"count": 35
}
为获取下一:
{
"target": "tiktok_api_hashtag",
"query": "tasty",
"count": 35,
"cursor": 35
}
旧目标
TikTok 资料(旧版)
POST https://scraper-api.smartdaili-china.com/v2/scrape
有效载荷类型: JSON
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
url | url | ✅ | TikTok 资料 URL | https://www.tiktok.com/@nba |
target | string | ✅ | 目标 | tiktok_profile |
locale | string | 语言环境 | en-GB | |
geo | string | 地理位置 | United States |
curl -u username:password -X POST --url https://scraper-api.smartdaili-china.com/v2/scrape -H "Content-Type: application/json" -d "{\"url\": \"https://www.tiktok.com/@nba\", \"target\": \"tiktok_profile\",\"locale\": \"en-us\",\"geo\": \"United States\" }"
import requests
headers = {
'Content-Type': 'application/json'
}
task_params = {
'url': 'https://www.tiktok.com/@nba',
'target': 'tiktok_profile',
'locale': 'en-us',
'geo': 'United States'
}
username = 'username'
password = 'password'
response = requests.post(
'https://scraper-api.smartdaili-china.com/v2/scrape',
headers = headers,
json = task_params,
auth = (username, password)
)
print(response.text)
<?php
$params = array(
'url' => 'https://www.tiktok.com/@nba',
'target' => 'tiktok_profile',
'locale' => 'en-us',
'geo' => 'United States'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://scraper-api.smartdaili-china.com/v2/scrape');
curl_setopt($ch, CURLOPT_USERPWD, 'username' . ':' . 'password');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_POST, 1);
$headers = array();
$headers[] = 'Content-Type: application/json';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
echo $result;
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
?>
TikTok 帖子(旧版)
POST https://scraper-api.smartdaili-china.com/v2/scrape
有效载荷类型: JSON
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
url | url | ✅ | TikTok 帖子 URL | https://www.tiktok.com/@nba/video/7196793231042989354 |
target | string | ✅ | 目标 | tiktok_post |
locale | string | 语言环境 | en-GB | |
geo | string | 地理位置 | United States |
curl -u username:password -X POST --url https://scraper-api.smartdaili-china.com/v2/scrape -H "Content-Type: application/json" -d "{\"url\": \"https://www.tiktok.com/@nba/video/7196793231042989354\", \"target\": \"tiktok_post\",\"locale\": \"en-us\",\"geo\": \"United States\" }"
import requests
headers = {
'Content-Type': 'application/json'
}
task_params = {
'url': 'https://www.tiktok.com/@nba/video/7196793231042989354',
'target': 'tiktok_post',
'locale': 'en-us',
'geo': 'United States'
}
username = 'username'
password = 'password'
response = requests.post(
'https://scraper-api.smartdaili-china.com/v2/scrape',
headers = headers,
json = task_params,
auth = (username, password)
)
print(response.text)
<?php
$params = array(
'url' => 'https://www.tiktok.com/@nba/video/7196793231042989354',
'target' => 'tiktok_post',
'locale' => 'en-us',
'geo' => 'United States'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://scraper-api.smartdaili-china.com/v2/scrape');
curl_setopt($ch, CURLOPT_USERPWD, 'username' . ':' . 'password');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_POST, 1);
$headers = array();
$headers[] = 'Content-Type: application/json';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
echo $result;
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
?>
TikTok 标签(旧版)
POST https://scraper-api.smartdaili-china.com/v2/scrape
有效载荷类型: JSON
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
url | url | ✅ | TikTok 标签 URL | https://www.tiktok.com/tag/satisfying |
target | string | ✅ | 目标 | tiktok_hashtag |
locale | string | 语言环境 | en-GB | |
geo | string | 地理位置 | United States |
curl -u username:password -X POST --url https://scraper-api.smartdaili-china.com/v2/scrape -H "Content-Type: application/json" -d "{\"url\": \"https://www.tiktok.com/tag/satisfying\", \"target\": \"tiktok_hashtag\",\"locale\": \"en-us\",\"geo\": \"United States\" }"
import requests
headers = {
'Content-Type': 'application/json'
}
task_params = {
'url': 'https://www.tiktok.com/tag/satisfying',
'target': 'tiktok_hashtag',
'locale': 'en-us',
'geo': 'United States'
}
username = 'username'
password = 'password'
response = requests.post(
'https://scraper-api.smartdaili-china.com/v2/scrape',
headers = headers,
json = task_params,
auth = (username, password)
)
print(response.text)
<?php
$params = array(
'url' => 'https://www.tiktok.com/tag/satisfying',
'target' => 'tiktok_hashtag',
'locale' => 'en-us',
'geo' => 'United States'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://scraper-api.smartdaili-china.com/v2/scrape');
curl_setopt($ch, CURLOPT_USERPWD, 'username' . ':' . 'password');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_POST, 1);
$headers = array();
$headers[] = 'Content-Type: application/json';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
echo $result;
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
?>
异步请求
异步请求不需要你保持打开的连接,并允许你稍后检索抓取的数据。若要了解更多信息,请查看本文。
Updated 3 months ago