restyler/tiktok-simple-scraper
Composer 安装命令:
composer require restyler/tiktok-simple-scraper
包简介
Simple Guzzle TikTok scraper, using Rapid API.
README 文档
README
This library is a Guzzle-based wrapper around RapidAPI solution which scrapes Tiktok.
Get your access key here: https://rapidapi.com/restyler/api/tiktok12
See /examples folder for examples
Installation
composer require restyler/tiktok-simple-scraper
Quick example:
getUserInfo(): Get user info by username
use TiktokScraper\Client; $tiktokClient = new Client([ 'rapidapi_key' => 'YOUR-RAPID-API_KEY' ] ); $response = $tiktokClient->getUserInfo([ 'username' => 'realmadrid', // 'second-proxy' => '1', - use fallback proxy in case you see weird errors like 404 for existing accounts. Every method supports this. ]); print_r($response); // response now contains array of user info. /* Array ( [secUid] => MS4wLjABAAAAdi4wJZtAiIre_rQ1KiFteDmtrGBDIyoleHRNsjL14-Enf8aVfkLUJ0l_LcJPZkiv [userId] => 6693776501107033094 [isSecret] => [uniqueId] => realmadrid [nickName] => Real Madrid C.F. [signature] => ⚽️ The official Real Madrid C.F. account 🏆 13 times European Champions [covers] => Array ( [0] => https://p77-sign-sg.tiktokcdn.com/imgurl [1] => https://p77-sign-sg.tiktokcdn.com/imgurl2 ) [coversMedium] => Array ( [0] => https://p77-sign-sg.tiktokcdn.com/imgurl3 [1] => https://p77-sign-sg.tiktokcdn.com/imgurl4 ) [following] => 8 [fans] => 3800000 [heart] => 28900000 [video] => 338 [verified] => 1 [digg] => 0 [ftc] => [relation] => -1 [openFavorite] => ) */
getUserFeed(): Get user feed by username
use TiktokScraper\Client; $tiktokClient = new Client([ 'rapidapi_key' => 'YOUR-RAPID-API_KEY' ] ); $response = $tiktokClient->getUserFeed([ 'username' => 'realmadrid', 'limit' => '10' ]); print_r($response); // response now contains array of user feed items.
getVideoInfo(): Get video info by video url
use TiktokScraper\Client; $tiktokClient = new Client([ 'rapidapi_key' => 'YOUR-RAPID-API_KEY' ] ); $response = $tiktokClient->getVideoInfo([ 'url' => 'https://www.tiktok.com/@tuzelitydance/video/6867065857240026369?sender_device=pc&sender_web_id=6842368731214956037&is_from_webapp=1' ]); print_r($response); // response now contains video result.
getMusicInfo(): Get music info by video url
use TiktokScraper\Client; $tiktokClient = new Client([ 'rapidapi_key' => 'YOUR-RAPID-API_KEY' ] ); $response = $tiktokClient->getMusicInfo([ 'url' => 'https://www.tiktok.com/music/Bad-Liar-6613051741099280390?lang=en' ]); print_r($response); // response now contains music result.
Proxy Fallback
This RapidAPI API uses fastest proxy available for the moment. It is problematic to detect when Tiktok bans some ip address, so if you use the API heavily Tiktok may start throwing 404 responses for existing resources. This can be mitigated by using distributed proxy network via &second-proxy=1 query param (available for all library public methods). Distributed proxy network is typically slower but ipractically impossible to ban.
Examples, Error Handling
See full example file here.
restyler/tiktok-simple-scraper 适用场景与选型建议
restyler/tiktok-simple-scraper 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 12 次下载、GitHub Stars 达 2, 最近一次更新时间为 2020 年 10 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 restyler/tiktok-simple-scraper 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 restyler/tiktok-simple-scraper 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 12
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2020-10-11