100分 求一php 批量采集-入库程序 | 有例子也可以。 求到再加300分! 就是一个简单的xmlHTTP自己写一个就好了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 anshenghao(幽雅的佐为) () 信誉:100 2006-9-30 16:28:46 删除 应该不会很难啊~~LZ说具体点~~ ============================比如一图书站吧~ 就拿 welan.com 打比方吧比如我们要采http://welan.com/1336987/首先要实现数据的采集:书名:作者:简介:定价:出版日期分类...======== 然后把采集到的信息存到可以 存到本地数据库一表中 id bookname author intrduce price pressdate class =============================要可以实现批量的采集 比如 利用正则采集 http://welan.com/1336987/ ~ 2800000 之间的所有图书.....就是这个意思咯~~~ *************************************很简单吗? 但我确实不会,看好几天了。。 就是使用file_get_contents取回远程页面,然后使用正则取出你需要的部分,再就是入库喽! 这个file_get_contents,然后分析,存入数据库 这个file_get_contents,然后分析,存入数据库==========================================关键在这个分析喽. 和你问同样的问题,也想知道答案:http://community.csdn.net/Expert/topic/5066/5066345.xml?temp=5.355471E-02 给你个图片采集类吧看一看就会了.class collect { var $url; //采集ULR(即采集目标) var $content; //原始内容 var $result;//采集结果 var $dir; //保存图片的目录var $trueid; //用作保存时文件的名字var $picname; //图片名 var $pictype; //图片类型 var $exist; //标记图片存在//========================================== // 函数: getUrl($url) // 功能: 构造函数,得到图片地址 // 参数: &$url 对象 //========================================== function getUrl($url,$dir,$trueid) { $this->url = $url; $this->dir = $dir; $this->trueid = $trueid; } //========================================== // 函数: getPType() // 功能: 构造函数,取得图片类别 // 参数: &$url 对象 //========================================== function getPType() { $end_str = substr($this->url,-5); if(eregi('.gif',$end_str)){ $this->pictype = "gif"; }elseif(eregi('.bmp',$end_str)){ $this->pictype = "bmp"; }elseif(eregi('.png',$end_str)){ $this->pictype = "png"; }else{ $this->pictype = "jpg"; } } //========================================== // 函数: getContent() // 功能: 构造函数,取得原始数据 // 参数: 无 //========================================== function getContent() { $fp = @fopen($this->url,"r"); if ($fp){ $this->exist = 1; while ($line = fgets($fp,1024)) { $this->content .= $line; } fclose($fp); }else { $this->exist = 0; } } //========================================== // 函数: getResult() // 功能: 构造函数,生成图片 // 参数: 无 //========================================== function getResult() { //$date = date("YmdHis"); $this->picname = $this->dir.$this->trueid.".".$this->pictype; if ($this->exist){ $fp = fopen($this->picname,"w"); if(fwrite($fp,$this->content)){ fclose ($fp); return 1; }else{ fclose ($fp); return 0; } }else{ return 2; } } //========================================== // 函数: getMsg() // 功能: 构造函数,返回信息 // 参数: 无 //========================================== function getMsg() { if ($this->getResult()==1) { echo "success<br>\n"; unset($this->content); }elseif ($this->getResult()==2) { echo "source file not exists<br>\n"; } else{ echo "file write error<br>\n"; unset($this->content); } } } 如何将日期格式转换为数字? 一种让我困惑好久的加密方式 怎么把表格做成这样的? 请问哪里可以下载到php 4.0.0(win32)?在线等候 dz的,要实现完全的rewrite,修改.htaccess文件,代码是什么 请问sum(XXX) 和limit 0,20不用一起用么? 请高手指点 为什么header函数重定向无用????????? 那里有PHP+MYSQL免费空间申请啊?? 会员登录页面登录按钮不跳转 发放Gmail邀请,90多个 PHP创建RSS聚合的疑问。
应该不会很难啊~~LZ说具体点~~
============================
比如一图书站吧~ 就拿 welan.com 打比方吧
比如我们要采http://welan.com/1336987/首先要实现数据的采集:
书名:
作者:
简介:
定价:
出版日期
分类
...
========
然后把采集到的信息存到可以 存到本地数据库一表中 id bookname author intrduce price pressdate class
=============================要可以实现批量的采集
比如 利用正则采集
http://welan.com/1336987/ ~ 2800000 之间的所有图书.....
就是这个意思咯~~~ *************************************很简单吗? 但我确实不会,看好几天了。。
==========================================
关键在这个分析喽.
看一看就会了.class collect
{
var $url; //采集ULR(即采集目标)
var $content; //原始内容
var $result;//采集结果
var $dir; //保存图片的目录
var $trueid; //用作保存时文件的名字
var $picname; //图片名
var $pictype; //图片类型
var $exist; //标记图片存在//==========================================
// 函数: getUrl($url)
// 功能: 构造函数,得到图片地址
// 参数: &$url 对象
//==========================================
function getUrl($url,$dir,$trueid)
{
$this->url = $url;
$this->dir = $dir;
$this->trueid = $trueid;
} //==========================================
// 函数: getPType()
// 功能: 构造函数,取得图片类别
// 参数: &$url 对象
//==========================================
function getPType()
{
$end_str = substr($this->url,-5);
if(eregi('.gif',$end_str)){
$this->pictype = "gif";
}elseif(eregi('.bmp',$end_str)){
$this->pictype = "bmp";
}elseif(eregi('.png',$end_str)){
$this->pictype = "png";
}else{
$this->pictype = "jpg";
}
} //==========================================
// 函数: getContent()
// 功能: 构造函数,取得原始数据
// 参数: 无
//==========================================
function getContent()
{
$fp = @fopen($this->url,"r");
if ($fp){
$this->exist = 1;
while ($line = fgets($fp,1024))
{
$this->content .= $line;
}
fclose($fp);
}else {
$this->exist = 0;
}
} //==========================================
// 函数: getResult()
// 功能: 构造函数,生成图片
// 参数: 无
//==========================================
function getResult()
{
//$date = date("YmdHis");
$this->picname = $this->dir.$this->trueid.".".$this->pictype;
if ($this->exist){
$fp = fopen($this->picname,"w");
if(fwrite($fp,$this->content)){
fclose ($fp);
return 1;
}else{
fclose ($fp);
return 0;
}
}else{
return 2;
}
} //==========================================
// 函数: getMsg()
// 功能: 构造函数,返回信息
// 参数: 无
//==========================================
function getMsg()
{
if ($this->getResult()==1)
{
echo "success<br>\n";
unset($this->content);
}elseif ($this->getResult()==2) {
echo "source file not exists<br>\n";
}
else{
echo "file write error<br>\n";
unset($this->content);
}
}
}