vsimke/article-finder
Composer 安装命令:
composer require vsimke/article-finder
包简介
Framework-agnostic PHP package for finding articles via Bing and Google SERP scraping using a chain-of-responsibility finder pattern.
README 文档
README
A framework-agnostic PHP package for finding published articles via Bing and Google SERP scraping, using a chain-of-responsibility finder pattern.
Given a site domain and article title, the package queries Bing first and falls back to Google if no sufficiently similar result is found. You can swap or extend the chain with your own finders.
Requirements
- PHP 8.2+
- Guzzle 7+
Installation
composer require vsimke/article-finder
Usage
Default chain (Bing → Google)
use Vsimke\ArticleFinder\ArticleFinder; use Vsimke\ArticleFinder\FinderParameter; use Vsimke\ArticleFinder\Scraper\HQueryScraper; $scraper = new HQueryScraper(); $finder = ArticleFinder::create($scraper); $result = $finder->find([ FinderParameter::SITE => 'example.com', FinderParameter::TITLE => 'My Article Title', ]); if ($result !== false) { echo $result['title']; // 'My Article Title' echo $result['link']; // 'https://example.com/my-article-title' echo $result['finder']; // 'www.bing.com' or 'www.google.com' }
ArticleFinder::find() returns array<string, string> on success or false when no match is found across the whole chain.
Dependency injection
use Vsimke\ArticleFinder\ArticleFinder; use Vsimke\ArticleFinder\FinderParameter; use Vsimke\ArticleFinder\Scraper\HQueryScraper; class ArticleOnlineChecker { public function __construct(private readonly ArticleFinder $finder) {} public function check(string $site, string $title): array|false { return $this->finder->find([ FinderParameter::SITE => $site, FinderParameter::TITLE => $title, ]); } } // Wire it up $checker = new ArticleOnlineChecker( ArticleFinder::create(new HQueryScraper()) );
Scraper options
Pass a custom ClientInterface or override the config array to control transport:
use GuzzleHttp\Client; use Vsimke\ArticleFinder\Scraper\HQueryScraper; // Custom Guzzle client (e.g. with a proxy) $client = new Client(['proxy' => 'socks5://127.0.0.1:1080']); $scraper = new HQueryScraper($client); // Override User-Agent $scraper = new HQueryScraper(config: [ 'headers' => [ 'User-Agent' => 'MyBot/1.0', ], ]);
Custom finder chain
Build your own chain by extending Finder and wiring it with setFinder():
use Vsimke\ArticleFinder\Finders\Finder; class DuckDuckGoFinder extends Finder { public function find(array $parameters): array { // ... scrape DuckDuckGo ... if ($article['link'] ?? null) { return $article; } return parent::find($parameters); // delegate to next in chain } } $ddg = new DuckDuckGoFinder(); $google = new GoogleArticleFinder($scraper); $ddg->chain($google); $finder->setFinder($ddg);
How it works
ArticleFinder::find()
└─ BingArticleFinder::find() ← queries www.bing.com
├─ match found → return result
└─ no match → GoogleArticleFinder::find() ← queries www.google.com
├─ match found → return result
└─ no match → [] → ArticleFinder returns false
A result is considered a match when similar_text() similarity between the SERP title and the search title exceeds 70%.
Note on fragility: SERP markup changes regularly. The parser fixture tests in
tests/Unit/are the safety net — update the fixtures if Bing or Google changes their HTML structure.
Development
Run tests
./vendor/bin/pest
Static analysis
./vendor/bin/phpstan analyse
Code style (PSR-12)
# Check only ./vendor/bin/pint --test # Fix ./vendor/bin/pint
Rector
# Dry run ./vendor/bin/rector process --dry-run # Apply ./vendor/bin/rector process
Release
.github/release.sh patch # 1.2.3 → 1.2.4 (default) .github/release.sh minor # 1.2.3 → 1.3.0 .github/release.sh major # 1.2.3 → 2.0.0
The script auto-detects the latest vX.Y.Z tag, bumps the requested segment, prompts for confirmation, then tags and pushes.
License
MIT — see LICENSE.
vsimke/article-finder 适用场景与选型建议
vsimke/article-finder 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 vsimke/article-finder 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 vsimke/article-finder 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 38
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-22