赞助广告 赞助广告
  当前位置:网络学院PHP技术XML应用 → www.xuxule.com 全站采集程序2
www.xuxule.com 全站采集程序2
日期:2005年10月16日 作者: 人气: 查看:[大字体 中字体 小字体]
<?PHP
define('ROOT_PATH', './');
set_time_limit(0);

$pic_dir = ROOT_PATH.'xuxule_pic/';
$dbusername="fuckmingliang";        //用户名
$dbpass="fuckmingliang";        //密码
$dbname="fuck";                //数据库
$dbhost="localhost";
mysql_connect($dbhost,$dbusername,$dbpass);
mysql_select_db($dbname);

#save special picture
#此处要注意。保存图片必须设置来源。否则不能下载。
function sava_pic($filename='',$str='')
{      
        global $pic_dir;
        $server  = 'www.xuxule.com';            
        $host    = 'www.xuxule.com';           
        $port    = 80;
        $target  = "/".$filename;
        $referer = 'http://'.$host.$target;    // Referer
      
        $File = fsockopen($server, $port, $errno, $errstr, 30);
        if (!$File)
        {
                echo "$errstr ($errno)<br />\n";
               
                return '';
        }
        else
        {
                $out = "GET $target HTTP/1.1\r\n";
                $out .= "Host: $host\r\n";
                $out .= "Referer: $referer\r\n";
                $out .= "Connection: Close\r\n\r\n";

                fputs($File, $out);


                $makeFile = $buffer = "";
                while ($buffer = fread($File,4096))
                {
                        $makeFile = $makeFile.$buffer;
                }
                fclose($File);

                preg_match("/Content-Length: (\d+)(.*)/s",$makeFile,$files);               
                $files[2] = ltrim($files[2]);
               
                $pic_name = time()."_".$str.".jpg";
                $Filename = $pic_dir.$pic_name;

                $fp = fopen ($Filename,'w+');
                fwrite($fp,$files[2]);
                fclose($fp);

                return $pic_name;
        }


}

$SQL = " SELECT * FROM xl_special where date='' ORDER BY specialID DESC ";//05-0248
$Result = mysql_query($SQL);
while ( $Row = mysql_fetch_array($Result) )
{      

        $url = "http://www.xuxule.com/cd.asp?cdID=".$Row['str'];
        $File = @file_Get_contents($url);
        if ( $File )
        {
               

                #save picture
                preg_match("/width=\"70\"(.*)border=1/s",$File,$pic2);
                preg_match("/href=(.{1,110}) target=_blank/",$pic2[1],$pic);
                $pic = sava_pic($pic[1],$Row['str']);

                preg_match("/专辑介绍(.*)<td> <\/td>/s",$File,$description2);#description
                preg_match("/<TD>(.*)<\/TD>/s",$description2[1],$description);#description

                preg_match("/出版年月(.*)<TD height=\"20\">&/s",$File,$date3);#date
                $st = preg_match("/:(.*)<TD height=\"20/s",$date3[1],$date2);#date
                if ( $st == 1 )
                {
                        preg_match("/(.*)<\/TD>/s",$date2[1],$date);#date
                        $date[1] = trim($date[1]);
                }
                else
                {
                        preg_match("/:(.*)<\/TD>/s",$date3[1],$datex);#date
                        $date[1] = trim($datex[1]);

                }

                preg_match("/发行公司:(.{1,100})<\/TD>/",$File,$company);#company
                preg_match("/专辑类别:(.{1,100})<\/TD>/",$File,$language);#language

                preg_match("/专辑曲目(.*)b_back/s",$File,$music2);#music num
                preg_match_all("/&songNo=(\d+) class=c>(.{1,100})<\/a>/",$music2[1],$music);#music num
                preg_match_all("/class=nolyric>(.{1,100})<\/span>/",$music2[1],$music_no);#music num

                 
                for ( $i=0;$i<count($music[1]);$i++)
                {      
                        $SQL = " INSERT INTO xl_lyric SET Name='".addslashes(trim($music[2][$i]))."',specialID='$Row[specialID]',specialName='".addslashes($Row[specialName])."',songerName='".addslashes($Row[songerName])."',songerID='$Row[songerID]',createDate='".time()."' ";
                        mysql_query($SQL);
                        $lyricID = $DB->_GetInsertID();

                        $lyricFile = @file_Get_contents("http://www.xuxule.com/lyric.asp?cdID=$Row[str]&songNo=".$music[1][$i]);
                        if ( $lyricFile )
                        {      
                                preg_match("/width=500>(.*)<td height=\"30/s",$lyricFile,$lyric3);#lyric
                                preg_match("/align=left>(.*)<\/tbody>/s",$lyric3[1],$lyric2);#lyric
                                preg_match("/(.*)<\/tr>/s",$lyric2[1],$lyric);#lyric
                              
                                $lyric[1] = str_replace("</td>","",$lyric[1]);
                                $SQL = " UPDATE xl_lyric SET lyric='".addslashes(trim($lyric[1]))."' WHERE lyricID='$lyricID' ";
                                mysql_query($SQL);
                        }
                }

                for ( $j=0;$j<count($music_no[1]);$j++)
                {
                        $SQL = " INSERT INTO xl_lyric SET Name='".addslashes(trim($music_no[1][$j]))."',specialID='$Row[specialID]',specialName='".addslashes($Row[specialName])."',songerName='".addslashes($Row[songerName])."',songerID='$Row[songerID]',createDate='".time()."' ";
                        mysql_query($SQL);
                }

                #insert into SQL
                $SQL = " UPDATE xl_special SET picture='$pic',
                description='".addslashes($description[1])."',
                company='".addslashes(trim($company[1]))."',
                date='".addslashes(trim($date[1]))."',
                language='".addslashes(trim($language[1]))."'

                WHERE specialID='$Row[specialID]' ";
                mysql_query($SQL);

                echo $SQL."<BR><bR>";
        }
      
}



?>

(出处:CodeFans转载)

相关文章:
 
·ASP中时间采集源程序
·浅谈自动采集程序及入库
·www.xuxule.com 全站采集程序
相关软件:
 
·新浪新闻采集程序 设计风美化版
·新浪新闻采集程序 设计风美化版
·网络信息采集专家 v0.9
·网站传神产品文章采集系列 (风讯版)1
·网站传神产品文章采集系列(风讯版) v3.01
·网站传神产品文章采集系列(动易版)
·PHOTO_21CN采集系统 v1.0
·WDO 通用信息采集系统 v0.9
·WDO 通用信息数据采集-房产新闻采集 v0.91
·心动采集类 v1.6
  特别推荐
  热点TOP10