# spider-utils-for-php **Repository Path**: mz/spider-utils-for-php ## Basic Information - **Project Name**: spider-utils-for-php - **Description**: 简单、易用、灵活的网络类,spider/network for PHP , too simple . - **Primary Language**: PHP - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 70 - **Forks**: 44 - **Created**: 2014-11-28 - **Last Updated**: 2025-06-13 ## Categories & Tags **Categories**: spider **Tags**: None ## README # spider PHP simple http client/spider class/简单的 PHP 的网络库 特色: - 简单易用 - HTTP 抓取和匹配 - 自动识别 HTML/XML 等文档编码为 utf-8 - 支持多 IP 出口设置 - 支持各类代理 ### Installation ``` composer require zv/spider ``` ### basic ``` $spider = new \ZV\Spider('https://www.baidu.com/s?wd=爱情&pn=50&rn=50&tn=json', [ //'User-Agent' => 'mobile', ]); $spider->GET(); print_r($spider->getResponseCode()); print_r($spider->getResponseHeader()); print_r($spider->getBody()); print_r($spider->getUrl()); print_r($spider->getJson()); ``` ### POST ``` use \ZV\Spider as spider; $spider = new spider('http://127.0.0.1/post', [ ]); $spider->POST([ 'query' => 1, // upload 'file1' => '@' . __FILE__, // upload file with MIME 'file2' => '@' . __FILE__ . ';text/plain' ]); print_r($spider->getBody()); ``` ### string utils ``` use \ZV\Spider as spider; // html2txt (has newline) echo spider::html2txt('