承接 haianibrahim/tiktok-scraper 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

haianibrahim/tiktok-scraper

最新稳定版本:v2.0.1

Composer 安装命令:

composer require haianibrahim/tiktok-scraper

包简介

Custom TikTok Video details scraper (PHP 8, PSR-4, Guzzle)

README 文档

README

GitHub Repo GitHub Stars Packagist Version PHP License Static Analysis

Scrape basic details from a public TikTok video URL in PHP. This is a cleaned-up, PSR‑4, PHP 8 rewrite using Guzzle and zero private APIs.

Features

  • Minimal public video details: canonical URL, IDs, username, nickname, description, thumbnail and counters
  • PSR‑4 autoloaded library with typed DTO output
  • Pluggable Guzzle client for testing and timeouts
  • No headless browser, no TikTok private API usage

Installation

Install via Composer:

composer require haianibrahim/tiktok-scraper

Quick Start

use GuzzleHttp\Client; // Or any ClientInterface
use Hki98\TikTok\TikTokScraper;

require __DIR__ . '/vendor/autoload.php';

$client = new Client();
$scraper = new TikTokScraper($client);

$details = $scraper->scrape('https://www.tiktok.com/@scout2015/video/6718335390845095173');

print_r($details->toArray());

Output shape:

  • status: "ok"
  • link
  • user (nickname)
  • username
  • user_id
  • video_id
  • video_desc
  • thumbnail
  • views, likes, comments, shares, favorites

API

  • TikTokScraper::scrape(string $url): VideoDetails
  • VideoDetails::toArray(): array

Exceptions

  • Base: Hki98\TikTok\Exception\TikTokScraperException (catch-all)
  • Specific:
    • Hki98\TikTok\Exception\InvalidUrlException
    • Hki98\TikTok\Exception\HttpRequestException
    • Hki98\TikTok\Exception\EmptyResponseException
    • Hki98\TikTok\Exception\ParseException

Notes

  • TikTok frequently changes HTML structure; this scraper parses the rehydration JSON in a script tag. If the key paths change, update the normalization method.
  • Respect robots.txt and terms of service in your jurisdiction.

Development

  • PHP 8.1+
  • PSR‑12 coding style recommended
  • Autoload: PSR‑4 under namespace Hki98\\TikTok (src/)

Run autoload dump after cloning:

composer dump-autoload

Credit

  • Original author: Haian K. Ibrahim (https://github.com/haianibrahim)
  • HTML parsing here is regex-based for one script tag; the bundled simple_html_dom.php is kept for historical context but not used by the new class.

License

GPL-3.0

统计信息

  • 总下载量: 11
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0
  • 更新时间: 2025-08-11