• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

php正则获取百度音乐排行榜top500

php 搞代码 4年前 (2022-01-22) 23次浏览 已收录 0个评论

本文介绍如何使用php正则表达式获取百度音乐排行榜top500数据,并显示在我们自己的网页中,

代码经本人调试成功,可作参考

代码如下:

取百度音乐排行榜top500 <title>百度音乐top500</title><style>body{font-size:12px;font-family:Verdana, Arial, Helvetica, sans-serif;}ul{clear:both;padding:0;margin:0;list-style:none;}#inner{width:960px;margin-left:auto;margin-right:auto;text-align:center;}#tableFrame{width:960px; /*需要修改*/border-top:#000 1px solid;border-left:#000 1px solid;font-size:12px;}#tableFrame:after {content: "."; display: block;height: 0; clear: both; visibility: hidden;}li{float:left;display: block;width:190px; /*需要修改*/height:41;padding:2px;margin:0;border-right:#000 1px solid;border-bottom:#000 1px solid;line-height:16px;color:000;overflow:scroll;}/* 表格标题*/#tableFrameTitle ul{}#tableFrameTitle<p style="color:transparent">。本文来源gao!%daima.com搞$代*!码网1</p><cite>搞代gaodaima码</cite> ul li{background:gray; text-align:center;color:#fff;}/* 表格内容*/#tableCase ul{}#tableCase ul li{}/* 单个表格特定样式*/.tableCaseThree{color:#329A02;}.tableCaseFive{color:#f00;}.tableCaseSeven{color:#f00;}</style><p id=inner><p id="tableFrame">    <p id="tableFrameTitle">        <ul>            <li>排名</li>            <li>歌名</li>            <li>排名变化趋势</li>            <li>红雨</li>            <li>RedRain</li>        </ul>    </p>    <p id="tableCase"><ul><?php$contents=file_get_contents("http://music.baidu.com/top/dayhot");$pattern="{<[^>]+song-title[^>]+><a href=\"(.*)\" title=\"(.*)\">}U";preg_match_all($pattern,$contents,$out,PREG_PATTERN_ORDER);$pattern1="{[1-9][0-9]{0,2}.*<i class=\"(.*)\"></i>}U";preg_match_all($pattern1,$contents,$out1,PREG_PATTERN_ORDER);$c=0;for($i=0;$i<500;$i++){if($c==5){$c=1;?></ul><ul><?php}else{$c++;}$get=$out[1][$i];$get1=$out[2][$i];$get2=$out1[1][$i];echo "<li>".iconv("utf-8","gb2312",($i+1).".<a href='http://music.baidu.com$get' target='_blank'>".$get1."</a><img src='../$get2.jpg'>")."</li>";}?></ul></p></p></p>

本文由搞代码提供,

文章地址:http://www.gaodaima.com/php-weizijiaocheng-377134.html

学编程就来搞代码 http://www.gaodaima.com

以上就是php正则获取百度音乐排行榜top500的详细内容,更多请关注搞代码gaodaima其它相关文章!


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:php正则获取百度音乐排行榜top500
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址