Download the PHP package zyan/v2d without Composer

On this page you can find all versions of the php package zyan/v2d. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package v2d

Zyan V2d

一个标准的短视频 APP 视频 / 图文抓取 SDK(Packagist 包),支持抖音、小红书、快手等平台,返回统一标准格式。

PHP

简介

zyan/v2d 用于从短视频平台的「分享链接」中抓取并解析出作品的标题、作者、封面、图片列表或视频地址,并统一为标准结构返回,便于做二次开发、内容归档、数据分析等。

支持平台

平台 标识 图文 视频 备注
抖音 (Douyin) douyin ✅ ✅ 通过 iesdouyin 分享页 _ROUTER_DATA 解析
快手 (Kuaishou) kuaishou ✅ ✅ 兼容移动端 v.m.chenzhongtech.com 与 __APOLLO_STATE__
小红书 (Xiaohongshu) xiaohongshu ✅ ✅ 服务器端易触发风控,需配置 Cookie(见 常见问题)

环境要求

安装

快速开始

也可以直接获取数组或 JSON:

标准返回格式

图文 ImageResult

视频 VideoResult

结果对象 API

方法 说明
getType() 内容类型:image / video
getPlatform() 平台标识
getUrl() 最终落地链接
getTitle() 标题(描述的首行)
getDesc() 完整描述
getAuthor() 作者对象(getId / getNickname / getAvatar)
getMusic() 背景音乐对象(getId / getTitle / getAuthor / getUrl / getCover / isEmpty)
getCover() 封面地址
getRaw() 平台原始数据
toArray() / toJson() 序列化输出
ImageResult::getImages() 图片地址列表
VideoResult::getVideos() 视频地址列表
VideoResult::getVideoUrl() 最优(首个)视频地址

单独使用适配器

如果只想针对单个平台,可直接使用对应适配器:

高级配置

注入 Cookie 绕过风控(小红书)

小红书对服务器端 IP 风控较严,直接抓取可能被重定向到安全校验页。可从浏览器中复制对应站点的 Cookie 注入:

获取方式:浏览器打开小红书笔记页 → F12 → Network → 任一请求 → 复制 Cookie 请求头。

自定义请求头

使用代理 / 自定义 HTTP 客户端

可注入任意 GuzzleHttp\ClientInterface 实现,配合代理、超时等:

自定义适配器

实现 AdapterInterface 即可接入新平台:

异常处理

所有异常均继承自 Zyan\V2d\Exceptions\Exception:

异常 触发场景
InvalidUrlException 链接无法被任何适配器识别
NetworkException 网络请求失败或返回 4xx/5xx
ParseException 页面结构变更或被风控,无法解析数据

测试

测试使用 Mock HTTP 客户端注入模拟页面,覆盖各平台图文 / 视频解析逻辑,不依赖网络,运行稳定。

常见问题

Q:小红书抓取报「触发了风控校验」? A:小红书对服务器端 IP 有严格风控,会重定向到安全校验 404 页。请通过 withCookie() 注入浏览器中真实的 Cookie,或使用代理 IP。

Q:抓取到的图片是高清图吗? A:抖音图集会尝试替换为原图参数;快手返回的即为平台 CDN 图集地址;如需更高清,可对返回 URL 自行调整参数。

Q:背景音乐的播放地址为什么有时候为空? A:抖音分享页出于版权保护,music 对象通常不返回播放地址(url 为空),但仍可获取曲名、艺人、封面等元信息;快手 soundTrack 会返回可播放的 audioUrls。

Q:链接失效或被删除? A:会抛出 ParseException,建议捕获后跳过或重试。

Q:平台页面结构变更导致解析失败? A:可在 Issue 中反馈,raw 字段保留了平台原始数据便于排查。

项目结构

贡献

欢迎通过 PR 接入更多平台或优化解析逻辑。请确保:

  1. 新增 / 修改逻辑附带对应的 PHPUnit 测试
  2. 遵循现有代码风格(PHP 7.4 兼容、强类型声明)
  3. composer test 通过

License

MIT License (c) zyan


All versions of v2d with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
guzzlehttp/guzzle Version ^6.5|^7.5
symfony/dom-crawler Version ^5.4
ext-json Version *
ext-mbstring Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package zyan/v2d contains the following files

Loading the files please wait ...