PHP音乐采集(部分代码)


Posted in PHP onFebruary 14, 2007

<?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("/发行公司:<\/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 相关文章推荐
自定义PHP分页函数
Oct 09 PHP
PHP5中使用PDO连接数据库的方法
Aug 01 PHP
thinkphp 一个页面使用2次分页的实现方法
Jul 15 PHP
PHP无限分类(树形类)
Sep 28 PHP
PHP goto语句简介和使用实例
Mar 11 PHP
Yii2使用dropdownlist实现地区三级联动功能的方法
Jul 18 PHP
php连接mysql数据库
Mar 21 PHP
PHP观察者模式定义与用法实例分析
Mar 22 PHP
Yii框架实现对数据库的CURD操作示例
Sep 03 PHP
在phpstudy集成环境下的nginx服务器下配置url重写
Dec 02 PHP
简单的php购物车代码
Jun 05 PHP
一个数据采集类
Feb 14 #PHP
phpmyadmin中配置文件现在需要绝密的短语密码的解决方法
Feb 11 #PHP
增加反向链接的101个方法 站长推荐
Jan 31 #PHP
Discuz!5的PHP代码高亮显示插件(黑暗中的舞者更新)
Jan 29 #PHP
解决控件遮挡问题:关于有窗口元素和无窗口元素
Jan 28 #PHP
获得Google PR值的PHP代码
Jan 28 #PHP
一键删除顽固的空文件夹 软件下载
Jan 26 #PHP
You might like
php中apc缓存使用示例
2013/12/25 PHP
php获取本周星期一具体日期的方法
2015/04/20 PHP
PHP获取链表中倒数第K个节点的方法
2018/01/18 PHP
thinkPHP5框架中widget的功能与用法详解
2018/06/11 PHP
php 利用socket发送GET,POST请求的实例代码
2020/07/04 PHP
formvalidator验证插件中有关ajax验证问题
2013/01/04 Javascript
css transform 3D幻灯片特效实现步骤解读
2013/03/27 Javascript
JavaScript var声明变量背后的原理示例解析
2013/10/12 Javascript
javascript表单验证和Window详解
2014/12/11 Javascript
javascript禁止超链接跳转的方法
2016/02/02 Javascript
Bootstrap 3浏览器兼容性问题及解决方案
2017/04/11 Javascript
Map.vue基于百度地图组件重构笔记分享
2017/04/17 Javascript
ElementUI radio组件选中小改造
2019/08/12 Javascript
JS如何实现网站中PC端和手机端自动识别并跳转对应的代码
2020/01/08 Javascript
jQuery+css实现的点击图片放大缩小预览功能示例【图片预览 查看大图】
2020/05/29 jQuery
vue实现移动端返回顶部
2020/10/12 Javascript
[50:22]完美盛典-2018年度红毯走秀
2018/12/16 DOTA
python实现保存网页到本地示例
2014/03/16 Python
Python入门篇之条件、循环
2014/10/17 Python
python根据出生日期返回年龄的方法
2015/03/26 Python
Python常见字符串操作函数小结【split()、join()、strip()】
2018/02/02 Python
python删除某个字符
2018/03/19 Python
numpy的文件存储.npy .npz 文件详解
2018/07/09 Python
python实现在图片上画特定大小角度矩形框
2018/10/24 Python
django如何通过类视图使用装饰器
2019/07/24 Python
python numpy数组复制使用实例解析
2020/01/10 Python
Pytorch之finetune使用详解
2020/01/18 Python
PyQt5实现画布小程序
2020/05/30 Python
Django实现内容缓存实例方法
2020/06/30 Python
解决Python 函数声明先后顺序出现的问题
2020/09/02 Python
CSS3 完美实现圆角效果
2009/07/13 HTML / CSS
几道Java和数据库的面试题
2013/05/30 面试题
竞选大队委员演讲稿
2014/04/28 职场文书
公司离职证明范本(汇总)
2014/09/10 职场文书
李白经典诗之一:全文无一“月”字,却句句有月
2019/07/12 职场文书
mysql多表查询-笔记七
2021/04/05 MySQL