+ -
当前位置:首页 → 问答吧 → Blog Movver for Baidu,有些粗糙,见笑

Blog Movver for Baidu,有些粗糙,见笑

时间:2008-03-08

来源:互联网

百度空间博客文章抓取Blog Movver for Baidu

有些粗糙,大家见笑
复制PHP内容到剪贴板
PHP代码:

<?
// Blog Mover for Baidu
// Verson : beta 1.0
// Date : 2008-3-6
// Copyright (C) 2008 Victor Su
// E-mail: [[email protected]][email protected][/email]
//
// This program is use to get the pepole's blog which on the site of [url=http://hi.baidu.com/]http://hi.baidu.com[/url] .
// With use it,you can catche as many of articles you want.
// This program is distributed in the hope that it will be useful.
// 

function replace($old,$new,$string){
$string=str_replace($old,$new,$string);
return $string;
}
class Mover{
var $host_url="[url=http://hi.baidu.com/]http://hi.baidu.com[/url]";
var $path="/blog/index/";
var $who="sujun";
var $message;
var $num=0;
var $count=0;
var $index=3;
var $article;
var $time_begin=0;
var $time_end=0;
var $time_use=0;
var $Host = "127.0.0.1";
var $DB = "vs_blog";
var $User = "root";
var $Pwd = "123456";
var $table = "vs_blog";
function Mover(){
  $conn=mysql_connect($this->Host,$this->User,$this->Pwd) or die("&Ecirc;&yacute;&frac34;&Yacute;&iquest;&acirc;&Aacute;&not;&frac12;&Oacute;&Ecirc;§°&Uuml;");
  while(!(mysql_select_DB($this->DB,$conn))){
   mysql_query("create database $this->DB");
  }
  $vs_sign=false;
  $result=mysql_list_tables($this->DB,$conn);
  while($row = mysql_fetch_row($result)){
   if($row[0]==$this->table){
    $vs_sign=true;
   }
  }
  mysql_free_result($result);
  if($vs_sign==false){
   mysql_query("
  CREATE TABLE $this->table (
  `id` int(20) NOT NULL auto_increment,
  `title` varchar(250) character set gbk NOT NULL,
  `author` varchar(100) character set gbk NOT NULL,
  `time`  varchar(20) character set gbk NOT NULL,
  `type` varchar(50) character set gbk NOT NULL,
  `content` mediumtext character set gbk NOT NULL,
  KEY `id` (`id`),
  KEY `type` (`type`),
  KEY `time` (`time`)
  ) 
   ");
  }
  mysql_query("set names 'gbk'");
}


function run($who,$begin_page,$end_page){
  set_time_limit(1000);
  $this->time_begin=microtime (true);
  for($n=$begin_page;$n<=$end_page;$n++){ 
   $url=$this->host_url."/".$who.$this->path;
   $url=$url.$n;
   $this->catche($url,"\"",3,"<div class=\"tit\">","</div>");
  }
  $this->time_end = microtime (true);
  ……

多谢下面两位大哥给我提醒,马上注释;
以后一定注意

[ 本帖最后由 sujun 于 2008-3-10 15:00 编辑 ]
Blog Mover for Baidu.rar (3.35 KB)

2008-3-10 15:00, 下载次数: 60

作者: sujun   发布时间: 2008-03-07

看不明白,希望能带点注释。

作者: chyoqin   发布时间: 2008-03-08

鼓励一下。

作者: luzhou   发布时间: 2008-03-08

引用:
原帖由 chyoqin 于 2008-3-8 09:46 发表
看不明白,希望能带点注释。
原创版区的好多帖子都有这通病,确实应该注重注释。

作者: luzhou   发布时间: 2008-03-08