淘宝商品价格比较的类
时间:2007-10-21
来源:互联网
实现主要功能:
1.指定关键字获取40条价格信息,卖家信息
2.根据制定价格范围来剔除一些和产品不符的价格信息。
3.每天获取一次价格保留在数据库中。
4.生成历史价格图标。
5.依据自己设定好规则生成自己店铺的指导价格。
如果有人感兴趣的话可以联系我:QQ:153080931 大家相互研究了。我想如果做出来应该对广大淘宝店主有用了。
PHP代码:
class taobao_analyse{var $code ;
var $price;
var $place;
var $seller;
var $seller_url;
var $product;
var $product_url;
var $info;
public function __construct($keywords){
//获取分析页面的源代码,注意keywords转换为url编码
$this->code = file_get_contents("[url=http://search1.taobao.com/browse/search_auction.htm?q=]http://search1.taobao.com/browse/search_auction.htm?q=".urlencode($keywords[/url]));
}
public function get_price(){
preg_match_all("/<span>([0-9]{1,5}\.[0-9]{2})<\/span>/i",$this->code,$price);
$this->price = $price[1];
}
public function get_place(){
preg_match_all("/<div class=\"Place\">([\S ]*)<\/div>/i",$this->code,$place);
$this->place= $place[1]; //获取商家所在地
}
public function get_product(){
preg_match_all("/<a [\S ]* class=\"EventCanSelect\">([\S ]*)<\/a>/i",$this->code,$product);
$this->product=$product[1]; //获取产品信息
$this->product_url=$product[0]; //获取产品信息的地址
}
public function get_seller(){
preg_match_all("/<a href=\"http:\/\/store\.taobao\.com\/shop\/view_shop\.htm\?user_id=[\S]*\" target=\"_blank\">([\S ]*)<\/a>/i",$this->code,$seller);
$this->seller=$seller[1]; //获取产品信息
$this->seller_url=$seller[0]; //获取产品信息的地址
}
public function get_info(){
$this->get_place();
$this->get_price();
$this->get_product();
$this->get_seller();
for ($i=0;$i<count($this->seller);$i++){
$this->info['seller'][]=$this->seller[$i];
$this->info['seller_url'][]=$this->seller_url[$i];
$this->info['product'][]=$this->product[$i];
$this->info['product_url'][]=$this->product_url[$i];
$this->info['place'][]=$this->place[$i];
$this->info['price'][]=$this->price[$i];
}
}
}
$taobao =new taobao_analyse("三星 2232GW+");
$taobao->get_info();
print_r($taobao->info);
[ 本帖最后由 morsth 于 2007-10-22 16:37 编辑 ]
作者: morsth 发布时间: 2007-10-20
发现做起来没有想的这么复杂
抓取价格正则
PHP代码:
<span>([0-9]{1,5}.[0-9]{2})</span>PHP代码:
<div class="Place\">([\S ]*)<\/div>PHP代码:
<a [S ]* class="EventCanSelect\">([\S ]*)<\/a>作者: morsth 发布时间: 2007-10-21
<span>15.00</span><br /><em>
</em>
只要匹配这些就行了!
楼主果然厉害那个链接你是怎么找出来的??
[ 本帖最后由 zhaofei299 于 2007-10-21 21:07 编辑 ]
作者: zhaofei299 发布时间: 2007-10-21
作者: morsth 发布时间: 2007-10-22
作者: zhaofei299 发布时间: 2007-10-22
作者: morsth 发布时间: 2007-10-22

作者: softly 发布时间: 2007-10-23
作者: morsth 发布时间: 2007-10-23
作者: yufenglx 发布时间: 2007-10-30
作者: morsth 发布时间: 2007-10-31
作者: morsth 发布时间: 2007-10-31
作者: netboys 发布时间: 2007-11-01
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28