netherphp / browser
轻量级网页请求。
dev-master
2024-07-10 20:25 UTC
Requires
- netherphp/common: dev-master
- symfony/css-selector: ^6.3
- symfony/dom-crawler: ^6.3
Requires (Dev)
- dealerdirect/phpcodesniffer-composer-installer: ^1.0
- netherphp/standards: ^0.2.9
- phpunit/phpunit: ^10.3
This package is auto-updated.
Last update: 2024-09-10 20:50:29 UTC
README
提供一种轻量级的方式来请求远程资源,理想情况下要考虑的错误情况最少,但这种情况还未出现。能够使用 PHP 的 file_get_contents()
或 cURL
扩展来获取远程资源。
use Nether\Browser; $Client = Browser\Client::FromURL('https://google.com/search?q=test'); // fetching generic data without any care as to what it may be. $Text = $Client->Fetch(); // fetching data expecting the remote to be valid json. returns an array on // success or null on failure. $Data = $Client->FetchAsJSON(); // array or NULL. // fetching data expecting the remote to be valid html. returns a Document on // success or null on failure. $HTML = $Client->FetchAsHTML(); // Browser\Document or NULL.