restyler / tiktok-simple-scraper
此包的最新版本(v1.0.0)没有可用的许可信息。
简单的Guzzle TikTok抓取器,使用Rapid API。
v1.0.0
2020-10-11 14:56 UTC
Requires
- guzzlehttp/guzzle: ^7.2
README
此库是围绕RapidAPI解决方案构建的Guzzle包装器,用于抓取Tiktok。
在这里获取您的访问密钥:[https://rapidapi.com/restyler/api/tiktok12](https://rapidapi.com/restyler/api/tiktok12)(外部链接)
请参阅 /examples 文件夹中的示例
安装
composer require restyler/tiktok-simple-scraper
快速示例
getUserInfo(): 通过用户名获取用户信息
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(): 通过用户名获取用户动态
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(): 通过视频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(): 通过视频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.
代理回退
此RapidAPI API使用目前可用的最快代理。当Tiktok禁止某些IP地址时,很难检测到,因此如果您大量使用API,Tiktok可能会开始对现有资源返回404响应。这可以通过使用通过&second-proxy=1
查询参数提供的分布式代理网络来缓解(适用于所有库公开方法)。分布式代理网络通常较慢,但在实际中几乎不可能被禁止。
示例,错误处理
请参阅完整的示例文件这里。