这个采集程序是一个非常简单的程序了,个人认为不适合于大量数据采集了单页还是没有问题了,因为fopen函数对于远程文件操作与多线程时是非常的不理想的,这个只是一个作者写的觉得好玩合出来了,代码如下:
utf8_iconv($content):";
}
/*获取所有匹配的内容
* @param string $str 内容
* @param string $start 起始匹配
* @param string $end 中止匹配
* @return array
*/
private function utf8_iconv($content) {
return iconv('GBK', 'UTF-8', $content);
}
private function strCutAll($str, $start, $end) {
$content = explode($start, $str);
$matchs = array();
$sum = count($content);
for ($i = 1; $i < $sum; $i++) {
$tmp = explode($end, $content[$i]);
$matchs[] = $tmp[0];
unset($tmp);
}
return $matchs;
}
/*获取第一个匹配的内容
* @param string $str 内容
* @param string $start 起始匹配
* @param string $end 中止匹配
* @return string
*/
private function strCut($str, $start, $end) {
$content = strstr($str, $start);
$content = substr($content, strlen($start) , strpos($content, $end) - strlen($start));
return $content;
}
?>/*采集程序*/
header("content-Type: text/html; charset=utf-8");
//$nr = file_get_contents(‘/webback/php/php-yi-ju-hua-hou-men-zhuan’);
$nr = $this->fetchbyurl(‘/webback/php/php-yi-ju-hua-hou-men-zhuan’);
//推荐,还可以用curl dump($this->strCut($nr,’’,'
相关文章
- 数字货币获国家批准的有哪些?数字货币交易所APP前十推荐
- SciTE中配置Go语言多步编译与执行:利用批处理脚本实现一键操作
- Golang的类型转换需要注意什么 演示安全转换与类型断言的区别
- Webman数据库迁移工具Phinx使用教程_PHP版本化数据库管理【教学】
- 如何在二维网格中根据线性索引精确设置指定位置为1
- xlm币是什么币种
- 如何使用Golang测试JSON序列化与反序列化_Golang encoding/json序列化测试方法
- Golang微服务中的RPC调用如何监控 Golang微服务RPC调用监控工具推荐
- php获取月头月末
- Yii框架怎么实现优惠券系统_Yii框架营销工具开发实战【详解】
