|
作者: zcz9999 [zcz9999] 论坛用户 | 登录 |
本帖由 [谗嘴猫] 从 << 影视音乐>> 转移而来将音乐的编号写到MYSQL中: #!/usr/bin/perl use LWP::UserAgent; use DBI; use URI; my $dbuser="music"; my $dbpasswd="********"; my $db="movie"; my $dbh=DBI->connect("DBI:mysql:$db",$dbuser,$dbpasswd); my $ua=new LWP::UserAgent; $jj=1; while ($jj<14){ $url=URI->new('http://www.qq986.com/index/Channel_'.$jj.".htm"); $channel=$ua->get($url)->content; if (length($channel)<900) {$jj++;next;} $channel=~/<title>[^<]+/; @c_=split(/ /,$&); print "type:".$c_[1]."::\n"; #@list=split(/<strong>/,$channel); @list=split(/size=4>/,$channel); $i=1; while ($list[$i]) { $abcd=substr($list[$i],0,1); print $abcd.":\n"; while ($list[$i]=~/special\/[^_]+_[0-9]{1,6}\.htm[^<]+/ig) { $b_=$&; $a_=$&; $a_=~/>.*/; $a_=substr($&,1,length($&)-1); $a_=~s/'//g; print "Curent NClass".$a_."\n"; ###start special $b_=~/special[^>]+/i; $url=URI->new('http://www.qq986.com/'.$&); $special=$ua->get($url)->content; if (length($special)<900) { print "No Special!\n";} else{ ###enter special while ($special=~/a title=[^>]+>[^<]+/ig){ $tmp=$&; $tmp=~/>[^<]+/; $special_name=substr($&,1,length($&)); $special_name=~s/['"]//; $tmp=~/http:[^>]+/; $special_url=$&; #print $special_url; #exit; $special_url=~s/['"]//g; ###enter special danji #print $special_url; #exit; $url=URI->new($special_url); $musiclist=$ua->get($url)->content; #print $musiclist; #exit; if (length($musiclist)<900){ print "No music!\n"; }else{ ###start list song while ($musiclist=~/[0-9]{1,2}\.<a[^>]+>[^<]+/gi){ $tmp_song_name=$&; $tmp=$&; $tmp=~/href=[^ ]+/; $tmp=substr($&,26,length($&)); #$tmp=$&; $tmp=~s/['"]//g; $song_url=$tmp; $tmp_song_name=~/>[^<]+/; $tmp_song_name=substr($&,1,length($&)); $tmp_song_name=~s/['"]//g; ###add song #print $song_url; #exit; $query="select * from MusicList_986 where Wma='$song_url' and MusicName='$tmp_song_name'"; $sth=$dbh->prepare($query); $rv=$sth->execute or print "select * from MusicList_986 error:$sth-errstr\n"; next if (@row=$sth->fetchrow_array); $query="insert into MusicList_986 (Wma,MusicName,Singer,SpecialID) values ('$song_url','$tmp_song_name','$a_','$special_name')"; #print $query; #exit; $sth=$dbh->prepare($query); $rv=$sth->execute or print "insert into MusicList error :$sth->errstr\n"; ###end add song } ###end list song } ###end enter specail danji ###add special to mysql $query="select * from Special_986 where name='$special_name' and NClass='$a_'"; $sth=$dbh->prepare($query); $rv=$sth->execute or print "Cant't select Special_986 :$sth->errstr\n"; next if (@row=$sth->fetchrow_array); $query="insert into Special_986 (name,NClass) values ('$special_name','$a_')"; $sth=$dbh->prepare($query); $rv=$sth->execute or print "insert into Special_986 error :$query\n"; ###end add special to mysql } ###out special } ###end special my $query="select NClass from NClass_986 where NClass = '$a_' and SClassID='$jj'"; $sth=$dbh->prepare($query); $rv=$sth->execute or print "Cant't execute the query:$sth->errstr\n"; next if (@row=$sth->fetchrow_array); $query="insert into NClass_986 (NClass,SClassID,Abcd) values ('$a_','$jj','$abcd')"; $sth=$dbh->prepare($query); $rv=$sth->execute or print "Cant't execute the query:$sth->errstr\n"; } print "NClass adder!\n"; $i++; } $query="select SClassid from SClass_986 where SClassid='$jj'"; $sth=$dbh->prepare($query); $rv=$sth->execute or print "Cant't execute the query:$sth->errstr\n"; if (@row=$sth->fetchrow_array) {$jj++;next;}; $query="insert into SClass_986 (SClassid,SClass) values ('$jj','$c_[1]')"; $sth=$dbh->prepare($query); $rv=$sth->execute or print "Cant't execute the query:$sth->errstr\n"; $jj++; print "SClass added!\n"; } 然后在网页上用PHP按编号实时找到此歌曲的真实播放地址: $fp=fopen("http://www.qq986.com/".$id,"r"); $buffer=fread($fp,65000); if (preg_match('/sUrl\+([^>]+)/i',$buffer,$buffer_)){ $row_Wma=substr($buffer_[1],1,strlen($buffer_[1])-3); #echo $row_Wma; #exit; } ?> <? $fp=fopen("http://www.qq986.com/js/play.js","r"); $buffer=fread($fp,500); preg_match('/sUrl=\"([^\"]+)/',$buffer,$buffer_); #echo $buffer_[1].$row_Wma; ?> <script> url="<? $addr=$buffer_[1].eregi_replace("%2F","/",urlencode(eregi_replace("\"","",$row_W ma))); preg_match('/http:\/\/([^\/]+)/',$addr,$match); $fp=fsockopen($match[1],80); #if (!$fp) return; $tmp="http://".$match[1]; 略......... QQ:307348688 行者 |
地主 发表时间: 05-08-29 14:54 |
回复: amao3273 [amao3273] 论坛用户 | 登录 |
强 佩服死了 |
B1层 发表时间: 05-08-31 16:36 |
回复: a103945764 [a103945764] 论坛用户 | 登录 |
谢谢大哥,但是我现在还连网站都还键不了啊 |
B2层 发表时间: 05-09-29 20:42 |
回复: Killu [collimator] 论坛用户 | 登录 |
不 明 |
B3层 发表时间: 05-10-13 08:51 |
回复: mensch1980 [mensch1980] 论坛用户 | 登录 |
这个就是传说中的盗链? 代码质量较差 连use strict; use warning;都没有 变量命名混乱 有HTMLParse不用,要用正则去慢慢匹配 程序结构混乱,就算是个小程序不用写成OO,也要定义成subroutine吧,不至于写成一堆 明明可以用do(),结果用prepare()+execute() |
B4层 发表时间: 05-10-15 07:39 |
|
20CN网络安全小组版权所有
Copyright © 2000-2010 20CN Security Group. All Rights Reserved.
论坛程序编写:NetDemon
粤ICP备05087286号