提取正则 preg_match_all正则有点麻烦.. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这个用正则好像有点不现实,既然是HTML的操作试试用DOMDocument操作吧。 jakey9826你真是一语惊醒梦中人啊太感谢你了 $pat = '/<td class=tdn>([0-9]+)<\/td>(.*?)<td>([0-9\.]+) M<\/td>/is';preg_match_all($pat,$str,$match);print_r($match);Array( [0] => Array ( [0] => <td class=tdn>1</td><td class=d><a href="http://220.181.38.82/m?ct=134217728&tn=baidusg,心跳 &word=mp3,http://video2.idaocao.com/wpynewvideo/musicup/Y2JjbGZoaG5iZWVrZm03.mp3,,[%D0%C4%CC%F8+%CD%F5%C1%A6%BA%EA]&si=%D0%C4%CC%F8;;%CD%F5%C1%A6%BA%EA;;624751;;624751&lm=16777216&sgid=1" title="请点击左键!来源网址: http://video2.idaocao.com 请参照百度权利声明使用" onclick="return ow(event,this)" target="_blank"><font color="#c60a00">心跳</font> </a></td><td><a href="http://mp3.baidu.com/singerlist/%CD%F5%C1%A6%BA%EA.html" target="_blank"><font color="#c60a00">王力宏</font></a> <a href="http://mp3.baidu.com/singerlist/.html" target="_blank"></a> <a href="http://mp3.baidu.com/singerlist/.html" target="_blank"></a> </td><td class=al><a href="http://mp3.baidu.com/albumlist/%CD%F5%C1%A6%BA%EA;;;;;;%D0%C4%CC%F8.html" target="_blank"><font color="#c60a00">心跳</font></a> </td><td><a href="http://box.zhangmen.baidu.com/m?gate=1&ct=134217728&tn=baidumt,心跳 &word=mp3,http://video2.idaocao.com/wpynewvideo/musicup/Y2JjbGZoaG5iZWVrZm03.mp3,,[%D0%C4%CC%F8+%CD%F5%C1%A6%BA%EA]&si=%D0%C4%CC%F8;;%CD%F5%C1%A6%BA%EA;;624751;;624751&lm=16777216&mtid=1&d=9" onclick="return ot(event,this,'624751')">试听</a> </td><td><a href="http://mp3.baidu.com/m?tn=baidump3lyric&word=%CD%F5%C1%A6%BA%EA+%D0%C4%CC%F8&ct=150994944&lm=-1&lf=3" target="_blank">歌词</a> </td><td> <a name="ls" href="http://mp3.baidu.com/tr?url=http://my.12530.com/newchannel/orderTone/600902000006213263/1/2703/2703_zlss/-/-/order.htm&sn=1" onclick="return or(event,this);">铃声</a> </td><td>5.2 M</td> [1] => <td class=tdn>2</td><td class=d><a href="http://220.181.38.82/m?ct=134217728&tn=baidusg,心跳 &word=mp3,http://www.sonymusic.cn/Manager/attachments/month_0812/amisl5RoZ2hpY2VsZmtsaGRiWHluW3BoVmt2WXprXHl0V3R1WntsXXJpWGx7W3xvVmpjWXdvXH1mV3V2Wnd5gJaTpaiXm5isMQ$$.mp3,,[%D0%C4%CC%F8+%CD%F5%C1%A6%BA%EA]&si=%D0%C4%CC%F8;;%CD%F5%C1%A6%BA%EA;;624751;;624751&lm=16777216&sgid=2" title="请点击左键!来源网址: http://www.sonymusic.cn 请参照百度权利声明使用" onclick="return ow(event,this)" target="_blank"><font color="#c60a00">心跳</font> </a></td><td><a href="http://mp3.baidu.com/singerlist/%CD%F5%C1%A6%BA%EA.html" target="_blank"><font color="#c60a00">王力宏</font></a> <a href="http://mp3.baidu.com/singerlist/.html" target="_blank"></a> <a href="http://mp3.baidu.com/singerlist/.html" target="_blank"></a> </td><td class=al><a href="http://mp3.baidu.com/albumlist/%CD%F5%C1%A6%BA%EA;;;;;;%D0%C4%CC%F8.html" target="_blank"><font color="#c60a00">心跳</font></a> </td><td><a href="http://box.zhangmen.baidu.com/m?gate=1&ct=134217728&tn=baidumt,心跳 &word=mp3,http://www.sonymusic.cn/Manager/attachments/month_0812/amisl5RoZ2hpY2VsZmtsaGRiWHluW3BoVmt2WXprXHl0V3R1WntsXXJpWGx7W3xvVmpjWXdvXH1mV3V2Wnd5gJaTpaiXm5isMQ$$.mp3,,[%D0%C4%CC%F8+%CD%F5%C1%A6%BA%EA]&si=%D0%C4%CC%F8;;%CD%F5%C1%A6%BA%EA;;624751;;624751&lm=16777216&mtid=2&d=9" onclick="return ot(event,this,'624751')">试听</a> </td><td><a href="http://mp3.baidu.com/m?tn=baidump3lyric&word=%CD%F5%C1%A6%BA%EA+%D0%C4%CC%F8&ct=150994944&lm=-1&lf=3" target="_blank">歌词</a> </td><td> <a name="ls" href="http://mp3.baidu.com/tr?url=http://my.12530.com/newchannel/orderTone/600902000006213263/1/2703/2703_zlss/-/-/order.htm&sn=2" onclick="return or(event,this);">铃声</a> </td><td>6.0 M</td> ) [1] => Array ( [0] => 1 [1] => 2 ) [2] => Array ( [0] => <td class=d><a href="http://220.181.38.82/m?ct=134217728&tn=baidusg,心跳 &word=mp3,http://video2.idaocao.com/wpynewvideo/musicup/Y2JjbGZoaG5iZWVrZm03.mp3,,[%D0%C4%CC%F8+%CD%F5%C1%A6%BA%EA]&si=%D0%C4%CC%F8;;%CD%F5%C1%A6%BA%EA;;624751;;624751&lm=16777216&sgid=1" title="请点击左键!来源网址: http://video2.idaocao.com 请参照百度权利声明使用" onclick="return ow(event,this)" target="_blank"><font color="#c60a00">心跳</font> </a></td><td><a href="http://mp3.baidu.com/singerlist/%CD%F5%C1%A6%BA%EA.html" target="_blank"><font color="#c60a00">王力宏</font></a> <a href="http://mp3.baidu.com/singerlist/.html" target="_blank"></a> <a href="http://mp3.baidu.com/singerlist/.html" target="_blank"></a> </td><td class=al><a href="http://mp3.baidu.com/albumlist/%CD%F5%C1%A6%BA%EA;;;;;;%D0%C4%CC%F8.html" target="_blank"><font color="#c60a00">心跳</font></a> </td><td><a href="http://box.zhangmen.baidu.com/m?gate=1&ct=134217728&tn=baidumt,心跳 &word=mp3,http://video2.idaocao.com/wpynewvideo/musicup/Y2JjbGZoaG5iZWVrZm03.mp3,,[%D0%C4%CC%F8+%CD%F5%C1%A6%BA%EA]&si=%D0%C4%CC%F8;;%CD%F5%C1%A6%BA%EA;;624751;;624751&lm=16777216&mtid=1&d=9" onclick="return ot(event,this,'624751')">试听</a> </td><td><a href="http://mp3.baidu.com/m?tn=baidump3lyric&word=%CD%F5%C1%A6%BA%EA+%D0%C4%CC%F8&ct=150994944&lm=-1&lf=3" target="_blank">歌词</a> </td><td> <a name="ls" href="http://mp3.baidu.com/tr?url=http://my.12530.com/newchannel/orderTone/600902000006213263/1/2703/2703_zlss/-/-/order.htm&sn=1" onclick="return or(event,this);">铃声</a> </td> [1] => <td class=d><a href="http://220.181.38.82/m?ct=134217728&tn=baidusg,心跳 &word=mp3,http://www.sonymusic.cn/Manager/attachments/month_0812/amisl5RoZ2hpY2VsZmtsaGRiWHluW3BoVmt2WXprXHl0V3R1WntsXXJpWGx7W3xvVmpjWXdvXH1mV3V2Wnd5gJaTpaiXm5isMQ$$.mp3,,[%D0%C4%CC%F8+%CD%F5%C1%A6%BA%EA]&si=%D0%C4%CC%F8;;%CD%F5%C1%A6%BA%EA;;624751;;624751&lm=16777216&sgid=2" title="请点击左键!来源网址: http://www.sonymusic.cn 请参照百度权利声明使用" onclick="return ow(event,this)" target="_blank"><font color="#c60a00">心跳</font> </a></td><td><a href="http://mp3.baidu.com/singerlist/%CD%F5%C1%A6%BA%EA.html" target="_blank"><font color="#c60a00">王力宏</font></a> <a href="http://mp3.baidu.com/singerlist/.html" target="_blank"></a> <a href="http://mp3.baidu.com/singerlist/.html" target="_blank"></a> </td><td class=al><a href="http://mp3.baidu.com/albumlist/%CD%F5%C1%A6%BA%EA;;;;;;%D0%C4%CC%F8.html" target="_blank"><font color="#c60a00">心跳</font></a> </td><td><a href="http://box.zhangmen.baidu.com/m?gate=1&ct=134217728&tn=baidumt,心跳 &word=mp3,http://www.sonymusic.cn/Manager/attachments/month_0812/amisl5RoZ2hpY2VsZmtsaGRiWHluW3BoVmt2WXprXHl0V3R1WntsXXJpWGx7W3xvVmpjWXdvXH1mV3V2Wnd5gJaTpaiXm5isMQ$$.mp3,,[%D0%C4%CC%F8+%CD%F5%C1%A6%BA%EA]&si=%D0%C4%CC%F8;;%CD%F5%C1%A6%BA%EA;;624751;;624751&lm=16777216&mtid=2&d=9" onclick="return ot(event,this,'624751')">试听</a> </td><td><a href="http://mp3.baidu.com/m?tn=baidump3lyric&word=%CD%F5%C1%A6%BA%EA+%D0%C4%CC%F8&ct=150994944&lm=-1&lf=3" target="_blank">歌词</a> </td><td> <a name="ls" href="http://mp3.baidu.com/tr?url=http://my.12530.com/newchannel/orderTone/600902000006213263/1/2703/2703_zlss/-/-/order.htm&sn=2" onclick="return or(event,this);">铃声</a> </td> ) [3] => Array ( [0] => 5.2 [1] => 6.0 )) 问题就是这样解决的。5楼 jakey9826 的无意之言点开了LZ的疑惑。 高薪求做PHP的毕设作业,在北京的最好 学网页的知识 [精华][视频教程] delphi for php 在线视频教程 php如何把gb2312字符串转换为unicode字符串呢? 关于离职 求助可不可以随机生成中英文数字的组合字符串 php文件能否直接用IE打开? redhatlinux8.0 的apache,怎么加载php? 哪位收藏了這文章:PHP安装、配置手册,http://www.csdn.net/Expert/TopicView1.asp?id=1008822 求大神帮助 买到票喽~虽然是25号的……除夕得在车上过了:) mysql查询语句问题
太感谢你了
$pat = '/<td class=tdn>([0-9]+)<\/td>(.*?)<td>([0-9\.]+) M<\/td>/is';
preg_match_all($pat,$str,$match);
print_r($match);Array
(
[0] => Array
(
[0] => <td class=tdn>1</td><td class=d><a href="http://220.181.38.82/m?ct=134217728&tn=baidusg,心跳 &word=mp3,http://video2.idaocao.com/wpynewvideo/musicup/Y2JjbGZoaG5iZWVrZm03.mp3,,[%D0%C4%CC%F8+%CD%F5%C1%A6%BA%EA]&si=%D0%C4%CC%F8;;%CD%F5%C1%A6%BA%EA;;624751;;624751&lm=16777216&sgid=1" title="请点击左键!来源网址: http://video2.idaocao.com 请参照百度权利声明使用" onclick="return ow(event,this)" target="_blank"><font color="#c60a00">心跳</font> </a></td>
<td><a href="http://mp3.baidu.com/singerlist/%CD%F5%C1%A6%BA%EA.html" target="_blank"><font color="#c60a00">王力宏</font></a> <a href="http://mp3.baidu.com/singerlist/.html" target="_blank"></a> <a href="http://mp3.baidu.com/singerlist/.html" target="_blank"></a> </td>
<td class=al><a href="http://mp3.baidu.com/albumlist/%CD%F5%C1%A6%BA%EA;;;;;;%D0%C4%CC%F8.html" target="_blank"><font color="#c60a00">心跳</font></a> </td>
<td><a href="http://box.zhangmen.baidu.com/m?gate=1&ct=134217728&tn=baidumt,心跳 &word=mp3,http://video2.idaocao.com/wpynewvideo/musicup/Y2JjbGZoaG5iZWVrZm03.mp3,,[%D0%C4%CC%F8+%CD%F5%C1%A6%BA%EA]&si=%D0%C4%CC%F8;;%CD%F5%C1%A6%BA%EA;;624751;;624751&lm=16777216&mtid=1&d=9" onclick="return ot(event,this,'624751')">试听</a> </td>
<td><a href="http://mp3.baidu.com/m?tn=baidump3lyric&word=%CD%F5%C1%A6%BA%EA+%D0%C4%CC%F8&ct=150994944&lm=-1&lf=3" target="_blank">歌词</a> </td>
<td> <a name="ls" href="http://mp3.baidu.com/tr?url=http://my.12530.com/newchannel/orderTone/600902000006213263/1/2703/2703_zlss/-/-/order.htm&sn=1" onclick="return or(event,this);">铃声</a> </td><td>5.2 M</td>
[1] => <td class=tdn>2</td>
<td class=d><a href="http://220.181.38.82/m?ct=134217728&tn=baidusg,心跳 &word=mp3,http://www.sonymusic.cn/Manager/attachments/month_0812/amisl5RoZ2hpY2VsZmtsaGRiWHluW3BoVmt2WXprXHl0V3R1WntsXXJpWGx7W3xvVmpjWXdvXH1mV3V2Wnd5gJaTpaiXm5isMQ$$.mp3,,[%D0%C4%CC%F8+%CD%F5%C1%A6%BA%EA]&si=%D0%C4%CC%F8;;%CD%F5%C1%A6%BA%EA;;624751;;624751&lm=16777216&sgid=2" title="请点击左键!来源网址: http://www.sonymusic.cn 请参照百度权利声明使用" onclick="return ow(event,this)" target="_blank"><font color="#c60a00">心跳</font> </a></td>
<td><a href="http://mp3.baidu.com/singerlist/%CD%F5%C1%A6%BA%EA.html" target="_blank"><font color="#c60a00">王力宏</font></a> <a href="http://mp3.baidu.com/singerlist/.html" target="_blank"></a> <a href="http://mp3.baidu.com/singerlist/.html" target="_blank"></a> </td>
<td class=al><a href="http://mp3.baidu.com/albumlist/%CD%F5%C1%A6%BA%EA;;;;;;%D0%C4%CC%F8.html" target="_blank"><font color="#c60a00">心跳</font></a> </td>
<td><a href="http://box.zhangmen.baidu.com/m?gate=1&ct=134217728&tn=baidumt,心跳 &word=mp3,http://www.sonymusic.cn/Manager/attachments/month_0812/amisl5RoZ2hpY2VsZmtsaGRiWHluW3BoVmt2WXprXHl0V3R1WntsXXJpWGx7W3xvVmpjWXdvXH1mV3V2Wnd5gJaTpaiXm5isMQ$$.mp3,,[%D0%C4%CC%F8+%CD%F5%C1%A6%BA%EA]&si=%D0%C4%CC%F8;;%CD%F5%C1%A6%BA%EA;;624751;;624751&lm=16777216&mtid=2&d=9" onclick="return ot(event,this,'624751')">试听</a> </td>
<td><a href="http://mp3.baidu.com/m?tn=baidump3lyric&word=%CD%F5%C1%A6%BA%EA+%D0%C4%CC%F8&ct=150994944&lm=-1&lf=3" target="_blank">歌词</a> </td><td> <a name="ls" href="http://mp3.baidu.com/tr?url=http://my.12530.com/newchannel/orderTone/600902000006213263/1/2703/2703_zlss/-/-/order.htm&sn=2" onclick="return or(event,this);">铃声</a> </td><td>6.0 M</td>
) [1] => Array
(
[0] => 1
[1] => 2
) [2] => Array
(
[0] => <td class=d><a href="http://220.181.38.82/m?ct=134217728&tn=baidusg,心跳 &word=mp3,http://video2.idaocao.com/wpynewvideo/musicup/Y2JjbGZoaG5iZWVrZm03.mp3,,[%D0%C4%CC%F8+%CD%F5%C1%A6%BA%EA]&si=%D0%C4%CC%F8;;%CD%F5%C1%A6%BA%EA;;624751;;624751&lm=16777216&sgid=1" title="请点击左键!来源网址: http://video2.idaocao.com 请参照百度权利声明使用" onclick="return ow(event,this)" target="_blank"><font color="#c60a00">心跳</font> </a></td>
<td><a href="http://mp3.baidu.com/singerlist/%CD%F5%C1%A6%BA%EA.html" target="_blank"><font color="#c60a00">王力宏</font></a> <a href="http://mp3.baidu.com/singerlist/.html" target="_blank"></a> <a href="http://mp3.baidu.com/singerlist/.html" target="_blank"></a> </td>
<td class=al><a href="http://mp3.baidu.com/albumlist/%CD%F5%C1%A6%BA%EA;;;;;;%D0%C4%CC%F8.html" target="_blank"><font color="#c60a00">心跳</font></a> </td>
<td><a href="http://box.zhangmen.baidu.com/m?gate=1&ct=134217728&tn=baidumt,心跳 &word=mp3,http://video2.idaocao.com/wpynewvideo/musicup/Y2JjbGZoaG5iZWVrZm03.mp3,,[%D0%C4%CC%F8+%CD%F5%C1%A6%BA%EA]&si=%D0%C4%CC%F8;;%CD%F5%C1%A6%BA%EA;;624751;;624751&lm=16777216&mtid=1&d=9" onclick="return ot(event,this,'624751')">试听</a> </td><td><a href="http://mp3.baidu.com/m?tn=baidump3lyric&word=%CD%F5%C1%A6%BA%EA+%D0%C4%CC%F8&ct=150994944&lm=-1&lf=3" target="_blank">歌词</a> </td>
<td> <a name="ls" href="http://mp3.baidu.com/tr?url=http://my.12530.com/newchannel/orderTone/600902000006213263/1/2703/2703_zlss/-/-/order.htm&sn=1" onclick="return or(event,this);">铃声</a> </td> [1] =>
<td class=d><a href="http://220.181.38.82/m?ct=134217728&tn=baidusg,心跳 &word=mp3,http://www.sonymusic.cn/Manager/attachments/month_0812/amisl5RoZ2hpY2VsZmtsaGRiWHluW3BoVmt2WXprXHl0V3R1WntsXXJpWGx7W3xvVmpjWXdvXH1mV3V2Wnd5gJaTpaiXm5isMQ$$.mp3,,[%D0%C4%CC%F8+%CD%F5%C1%A6%BA%EA]&si=%D0%C4%CC%F8;;%CD%F5%C1%A6%BA%EA;;624751;;624751&lm=16777216&sgid=2" title="请点击左键!来源网址: http://www.sonymusic.cn 请参照百度权利声明使用" onclick="return ow(event,this)" target="_blank"><font color="#c60a00">心跳</font> </a></td>
<td><a href="http://mp3.baidu.com/singerlist/%CD%F5%C1%A6%BA%EA.html" target="_blank"><font color="#c60a00">王力宏</font></a> <a href="http://mp3.baidu.com/singerlist/.html" target="_blank"></a> <a href="http://mp3.baidu.com/singerlist/.html" target="_blank"></a> </td>
<td class=al><a href="http://mp3.baidu.com/albumlist/%CD%F5%C1%A6%BA%EA;;;;;;%D0%C4%CC%F8.html" target="_blank"><font color="#c60a00">心跳</font></a> </td>
<td><a href="http://box.zhangmen.baidu.com/m?gate=1&ct=134217728&tn=baidumt,心跳 &word=mp3,http://www.sonymusic.cn/Manager/attachments/month_0812/amisl5RoZ2hpY2VsZmtsaGRiWHluW3BoVmt2WXprXHl0V3R1WntsXXJpWGx7W3xvVmpjWXdvXH1mV3V2Wnd5gJaTpaiXm5isMQ$$.mp3,,[%D0%C4%CC%F8+%CD%F5%C1%A6%BA%EA]&si=%D0%C4%CC%F8;;%CD%F5%C1%A6%BA%EA;;624751;;624751&lm=16777216&mtid=2&d=9" onclick="return ot(event,this,'624751')">试听</a> </td><td><a href="http://mp3.baidu.com/m?tn=baidump3lyric&word=%CD%F5%C1%A6%BA%EA+%D0%C4%CC%F8&ct=150994944&lm=-1&lf=3" target="_blank">歌词</a> </td>
<td> <a name="ls" href="http://mp3.baidu.com/tr?url=http://my.12530.com/newchannel/orderTone/600902000006213263/1/2703/2703_zlss/-/-/order.htm&sn=2" onclick="return or(event,this);">铃声</a> </td>
) [3] => Array
(
[0] => 5.2
[1] => 6.0
))
5楼 jakey9826 的无意之言点开了LZ的疑惑。