PHP音乐采集(部分代码)
2015-01-24信息快讯网
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("/发行公司:<\/strong>(.*)/",$songer[1],$company);#发行公司
preg_match("/发行时间<\/strong>:(.*)<\/td> <\/tr>/",$makeFile,$date);#发行时间
preg_match("/(.*)<\/td>/",$date[1],$date2);#发行时间
preg_match("/<\/strong>(.*)/",$date[1],$language);#发行语言
preg_match("/专辑简介:<\/strong><\/td> <td colspan=2>(.*)<\/td><\/tr><\/table><br>/",$makeFile,$descript);#专辑简介
$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);
}
}
?>
php中$this->含义分析
php self,$this,const,static,->的使用
PHP nl2br函数 将换行字符转成 <br>
PHP 源代码分析 Zend HashTable详解第1/3页
PHP file_get_contents 函数超时的几种解决方法
php strlen mb_strlen计算中英文混排字符串长度
php 分页函数multi() discuz
php array_map array_multisort 高效处理多维数组排序
PHP加速 eAccelerator配置和使用指南
php split汉字
php 无限级 SelectTree 类
AspNetAjaxPager,Asp.Net通用无刷新Ajax分页控件,支持多样式多数据绑定
PHPMailer安装方法及简单实例
php下HTTP Response中的Chunked编码实现方法
PHPMailer邮件类利用smtp.163.com发送邮件方法
php htmlentities和htmlspecialchars 的区别
PHP 得到根目录的 __FILE__ 常量
php sprintf()函数让你的sql操作更安全
PHP_MySQL教程-第二天while循环与数据库操作第1/2页
php中的一个中文字符串截取函数
一个数据采集类
获得Google PR值的PHP代码
PHP 的 __FILE__ 常量
MySQL中create table语句的基本语法是
用php实现像JSP,ASP里Application那样的全局变量
ob_start(),ob_start('ob_gzhandler')使用
echo, print, printf 和 sprintf 区别
<b>一些常用的php函数</b>
html中select语句读取mysql表中内容
利用PHP实现与ASP Banner组件相似的类
PHP VS ASP
PHP的ASP防火墙
使用php+xslt在windows平台上
php+dbfile开发小型留言本
新版百元变化更能防伪 收藏越稀缺越值钱