代码拉取完成,页面将自动刷新
同步操作将从 mz/spider-utils-for-php 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
spider-utils-for-php:
##原则:
简单、易用、灵活、任性任性任性就是任性!
##特色:
##什么?转换相对路径到绝对路径
// $result = http://baidu.com/bac/index.html
$result = spider::abs_url('http://baidu.com/abc/', '../bac/index.html');
##什么?html2txt?
// $result = 123
$result = spider::html2txt('<p><a href="">1</a>23<p>');
##什么?字符串截取?
// $result = 23abcde
$result = spider::cut_str('123abcdef', '1', 'f');
##什么?通配符匹配?
// $result = abc
$result = spider::mask_match('123abc123', '123(*)123');
// $result = abc
$result = spider::mask_match('abc123', '(*)123');
// $result = 123
$result = spider::mask_match('123abcabc', '(*)abc');
// $result = 123abc
$result = spider::mask_match('123abcdef', '(*)abc', true);
##What?发送http GET请求?
// 自动转码 utf-8,
$result = spider::fetch_url('http://www.baidu.com/');
##What?发送http POST请求?
$post = "wd=".urlencode("你的网址");
// 数组也一样
// $post = array("wd" => urlencode("你的网址"));
$result = spider::fetch_url('http://www.baidu.com/s?',$post);
##What?POST File?
$post = array("wd" => "http://", "file" => "@c:/1.txt");
$result = spider::fetch_url('http://www.baidu.com/s?',$post);
##What?要带 UserAgent 和 Cookie?
// 一切 headers 都可以传入
$headers = array(
'Cookie' => 'uid=1; my_name_is=mzphp',
'UserAgent' => 'userAgentForIphone',
'Referer' => 'http://baidu.com/',
);
$result = spider::fetch_url('http://www.baidu.com/s?', $post, $headers);
##What?这些操作如何漂亮的“在一起”?
// 首先你需要一个女朋友
$key = "魔爪小说阅读器";
$url = 'http://www.sogou.com/web?query='.urlencode($key).'&ie=utf8';
$html = spider::fetch_url($url, '', array('Referer'=>'http://www.sogou.com/'));
// 对你的女朋友进行分析
$keywordlist = spider::match($html, array('list'=>array(
'cut' => '相关搜索</caption>(*)</tr></table>',
'pattern' => '#id="sogou_\d+_\d+">(?<key>[^>]*?)</a>#is',
)));
//
$newarr = array();
foreach($keywordlist['list'] as $key=>$val){
$newarr[$val['key']] = array('key'=>$val['key']);
}
##更多?
好吧,你可以参考一下 mzphp2 项目中的 start_example 里的index_control,on_spider 方法:
http://git.oschina.net/mz/mzphp2/blob/master/start_example/control/index_control.class.php
##注:
mime_content_type 方法需要 php 开启 finfo
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。