• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

spider-utils-for-php: 简单、易用、灵活的网络类,spider/network for PHP , too sim ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

spider-utils-for-php

开源软件地址:

https://gitee.com/mz/spider-utils-for-php

开源软件介绍:

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('<h1>html2txt</h1>'), PHP_EOL,// no html(without newline)spider::noHtml('<h1>noHtml</h1>'), PHP_EOL,// strip_tagsspider::strip_tags('<h1>strip_tags</h1>'), PHP_EOL,// cut strspider::cut('<h1>cut</h1>', '<h1>', '</h1>'), PHP_EOL,    // match with maskspider::maskMatch('<h1>maskMatch</h1>', '<h1>(*)</h1>'), PHP_EOL,    // match with regexpspider::regMatch('<h1>regMatch</h1>', '#<h1>([^>]*?)</h1>#is'), PHP_EOL,    // match with multi patternprint_r(spider::match('<h1>MatchByMultiPattern</h1><h2>Description</h2>', [    'title' => '#<h1>([^>]*?)</h1>#is',    'desc'  => '<h2>(*)</h2>']), 1), PHP_EOL;

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap