淘宝可以通过
http://search1.taobao.com/browse/search_auction.htm?q=** 来搜索产品,打算通过制定关键字,来搜索和自己相关产品,关注同行价格。不知道目前有没有这样的程序实现。因为本人既非专业程序开发,也非专业web开发人员。水平有限,在VB.net 与php之间权衡了下决定还是选用PHP. 主要技术手段很简单了:就是web抓取分析页面了。
实现主要功能:
1.指定关键字获取40条价格信息,卖家信息
2.根据制定价格范围来剔除一些和产品不符的价格信息。
3.每天获取一次价格保留在数据库中。
4.生成历史价格图标。
5.依据自己设定好规则生成自己店铺的指导价格。
如果有人感兴趣的话可以联系我:QQ:153080931 大家相互研究了。我想如果做出来应该对广大淘宝店主有用了。
复制内容到剪贴板
代码:
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("/([0-9]{1,5}\.[0-9]{2})<\/span>/i",$this->code,$price);
$this->price = $price[1];
}
public function get_place(){
preg_match_all("/
([\S ]*)<\/div>/i",$this->code,$place);
$this->place= $place[1]; //获取商家所在地
}
public function get_product(){
preg_match_all("/([\S ]*)<\/a>/i",$this->code,$product);
$this->product=$product[1]; //获取产品信息
$this->product_url=$product[0]; //获取产品信息的地址
}
public function get_seller(){
preg_match_all("/([\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;$iseller);$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);