PHP音樂采集(部分代碼)
更新時(shí)間:2007年02月14日 00:00:00 作者:
<?PHP
set_time_limit(0);
mysql_connect("localhost","root","");
mysql_select_Db("music_36g");
$ip = '127.0.0.1';
function _GetIP()
{
$ip = getenv("REMOTE_ADDR");
$ip1 = getenv("HTTP_X_FORWARDED_FOR");
$ip2 = getenv("HTTP_CLIENT_IP");
($ip1) ? $ip = $ip1 : null ;
($ip2) ? $ip = $ip2 : null ;
return $ip;
}
function MakePassword($length=10)
{
$password = '';
$chars =
array
(
"1","2","3","4","5","6","7","8","9","0",
"a","A","b","B","c","C","d","D","e","E","f","F","g","G","h","H","i","I","j","J",
"k","K","l","L","m","M","n","N","o","O","p","P","q","Q","r","R","s","S","t","T",
"u","U","v","V","w","W","x","X","y","Y","z","Z"
);
$count = count($chars) - 1;
srand((double)microtime()*1000000);
for($i = 0; $i < $length; $i++)
{
$password .= $chars[rand(0, $count)];
}
return($password);
}
if ( _GetIP() != $ip )
{
exit("Can't Run!");
}
for ( $i=2;$i<5769;$i++)//52738
{
$url = "http://music.36g.net/SpecialInfo/showspecial".$i.".htm";
$File = @fopen($url,'rb');
if ( $File )
{
$makeFile = $buffer = "";
$buffer = "";
while ($buffer = fread($File,4096))
{
$makeFile = $makeFile.$buffer;
}
@fclose($File);
preg_match("/src=\/uppic\/(.*) width=135/",$makeFile,$pic);#圖片
#下載圖片
if ( $pic[1]!='es/Nophoto.gif' )
{
$p_url = "http://music.36g.net/uppic/".$pic[1];
$File2 = fopen($p_url,'rb');
if ( $File2 )
{
$Buffer2 = $makeFile2 = "";
while ($Buffer2 = fread($File2,4096))
{
$makeFile2 = $makeFile2.$Buffer2;
}
fclose($File2);
$Filename2 = './pic/'.$pic[1];
$Fp2 = fopen ($Filename2,'w+');
fwrite($Fp2,$makeFile2);
fclose($Fp2);
}
}
else
{
$pic[1] = '';
}
preg_match("/專輯:<\/strong>(.*)<\/td><td width=(\d+) rowspan=6/",$makeFile,$name);#專輯名稱
$name = addslashes($name[1]);
preg_match("/歌手:<\/strong>(.*)<\/td><\/tr><tr><td>/",$makeFile,$songer);#歌手名稱
preg_match("/(.*)<\/td><\/tr><tr><td>/",$songer[1],$songer_name);#歌手名稱
preg_match("/發(fā)行公司:<\/strong>(.*)/",$songer[1],$company);#發(fā)行公司
preg_match("/發(fā)行時(shí)間<\/strong>:(.*)<\/td> <\/tr>/",$makeFile,$date);#發(fā)行時(shí)間
preg_match("/(.*)<\/td>/",$date[1],$date2);#發(fā)行時(shí)間
preg_match("/<\/strong>(.*)/",$date[1],$language);#發(fā)行語言
preg_match("/專輯簡(jiǎn)介:<\/strong><\/td> <td colspan=2>(.*)<\/td><\/tr><\/table><br>/",$makeFile,$descript);#專輯簡(jiǎn)介
$songer_name = addslashes($songer_name[1]);
$company= addslashes($company[1]);
$descript= addslashes($descript[1]);
#取得歌曲ID
preg_match_all("/download1\.asp\?id=(\d+)&which=BakDownUrl1/",$makeFile,$id2);#歌曲ID
$num = count($id2[1]);
for ($jj=0;$jj<$num;$jj++)
{
$sql = " insert into tx_music set musicID='".$id2[1][$jj]."',specialID='$i',specialName='$name',songerName='$songer_name',orderByID='".$id2[1][$jj]."' ";
//echo $id2[1][$jj]."<br>";
mysql_query($sql);
}
//echo $descript."<br><br>";
$sql = " insert into tx_special set orderByID='$i',specialID='$i',specialName='$name',songerName='$songer_name',company='$company',date='$date2[1]',language='$language[1]',picture='$pic[1]',musicNum='$num',createDate='".time()."',description='$descript' ";
echo $sql;
mysql_query($sql);
}
}
?>
set_time_limit(0);
mysql_connect("localhost","root","");
mysql_select_Db("music_36g");
$ip = '127.0.0.1';
function _GetIP()
{
$ip = getenv("REMOTE_ADDR");
$ip1 = getenv("HTTP_X_FORWARDED_FOR");
$ip2 = getenv("HTTP_CLIENT_IP");
($ip1) ? $ip = $ip1 : null ;
($ip2) ? $ip = $ip2 : null ;
return $ip;
}
function MakePassword($length=10)
{
$password = '';
$chars =
array
(
"1","2","3","4","5","6","7","8","9","0",
"a","A","b","B","c","C","d","D","e","E","f","F","g","G","h","H","i","I","j","J",
"k","K","l","L","m","M","n","N","o","O","p","P","q","Q","r","R","s","S","t","T",
"u","U","v","V","w","W","x","X","y","Y","z","Z"
);
$count = count($chars) - 1;
srand((double)microtime()*1000000);
for($i = 0; $i < $length; $i++)
{
$password .= $chars[rand(0, $count)];
}
return($password);
}
if ( _GetIP() != $ip )
{
exit("Can't Run!");
}
for ( $i=2;$i<5769;$i++)//52738
{
$url = "http://music.36g.net/SpecialInfo/showspecial".$i.".htm";
$File = @fopen($url,'rb');
if ( $File )
{
$makeFile = $buffer = "";
$buffer = "";
while ($buffer = fread($File,4096))
{
$makeFile = $makeFile.$buffer;
}
@fclose($File);
preg_match("/src=\/uppic\/(.*) width=135/",$makeFile,$pic);#圖片
#下載圖片
if ( $pic[1]!='es/Nophoto.gif' )
{
$p_url = "http://music.36g.net/uppic/".$pic[1];
$File2 = fopen($p_url,'rb');
if ( $File2 )
{
$Buffer2 = $makeFile2 = "";
while ($Buffer2 = fread($File2,4096))
{
$makeFile2 = $makeFile2.$Buffer2;
}
fclose($File2);
$Filename2 = './pic/'.$pic[1];
$Fp2 = fopen ($Filename2,'w+');
fwrite($Fp2,$makeFile2);
fclose($Fp2);
}
}
else
{
$pic[1] = '';
}
preg_match("/專輯:<\/strong>(.*)<\/td><td width=(\d+) rowspan=6/",$makeFile,$name);#專輯名稱
$name = addslashes($name[1]);
preg_match("/歌手:<\/strong>(.*)<\/td><\/tr><tr><td>/",$makeFile,$songer);#歌手名稱
preg_match("/(.*)<\/td><\/tr><tr><td>/",$songer[1],$songer_name);#歌手名稱
preg_match("/發(fā)行公司:<\/strong>(.*)/",$songer[1],$company);#發(fā)行公司
preg_match("/發(fā)行時(shí)間<\/strong>:(.*)<\/td> <\/tr>/",$makeFile,$date);#發(fā)行時(shí)間
preg_match("/(.*)<\/td>/",$date[1],$date2);#發(fā)行時(shí)間
preg_match("/<\/strong>(.*)/",$date[1],$language);#發(fā)行語言
preg_match("/專輯簡(jiǎn)介:<\/strong><\/td> <td colspan=2>(.*)<\/td><\/tr><\/table><br>/",$makeFile,$descript);#專輯簡(jiǎn)介
$songer_name = addslashes($songer_name[1]);
$company= addslashes($company[1]);
$descript= addslashes($descript[1]);
#取得歌曲ID
preg_match_all("/download1\.asp\?id=(\d+)&which=BakDownUrl1/",$makeFile,$id2);#歌曲ID
$num = count($id2[1]);
for ($jj=0;$jj<$num;$jj++)
{
$sql = " insert into tx_music set musicID='".$id2[1][$jj]."',specialID='$i',specialName='$name',songerName='$songer_name',orderByID='".$id2[1][$jj]."' ";
//echo $id2[1][$jj]."<br>";
mysql_query($sql);
}
//echo $descript."<br><br>";
$sql = " insert into tx_special set orderByID='$i',specialID='$i',specialName='$name',songerName='$songer_name',company='$company',date='$date2[1]',language='$language[1]',picture='$pic[1]',musicNum='$num',createDate='".time()."',description='$descript' ";
echo $sql;
mysql_query($sql);
}
}
?>
相關(guān)文章
mysql_connect localhost和127.0.0.1的區(qū)別(網(wǎng)絡(luò)層闡述)
這篇文章主要介紹了mysql_connect localhost和127.0.0.1的區(qū)別(網(wǎng)絡(luò)層闡述),本文從網(wǎng)絡(luò)通信層面講解了它們的不同,需要的朋友可以參考下2015-03-03
PHP如何使用array_unshift()在數(shù)組開頭插入元素
這篇文章主要介紹了PHP如何使用array_unshift()在數(shù)組開頭插入元素,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-09-09
提高define性能的php擴(kuò)展hidef的安裝和使用
在apache啟動(dòng)前,PHP啟動(dòng)時(shí)創(chuàng)建并初始化了這些常量,這樣就不需要在php里define常量了,性能自然沒有任何問題了!2011-06-06
PHP生成可點(diǎn)擊刷新的驗(yàn)證碼簡(jiǎn)單示例
這篇文章主要介紹了PHP生成可點(diǎn)擊刷新的驗(yàn)證碼,結(jié)合簡(jiǎn)單實(shí)例形式分析了php驗(yàn)證碼的實(shí)現(xiàn)與調(diào)用顯示方法,涉及js動(dòng)態(tài)調(diào)用驗(yàn)證碼php文件的相關(guān)技巧,需要的朋友可以參考下2016-05-05
php setcookie(name, value, expires, path, domain, secure) 參數(shù)
本篇文章是對(duì)php setcookie(name, value, expires, path, domain, secure) 參數(shù)進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-06-06
PHP中使用json數(shù)據(jù)格式定義字面量對(duì)象的方法
這篇文章主要介紹了PHP中使用json數(shù)據(jù)格式定義字面量對(duì)象的方法,這是一種變通方法,使用json還可以在類中生成數(shù)組哦,需要的朋友可以參考下2014-08-08

