日期:2014-05-17  浏览次数:21937 次

提取HTML代码中的磁力链接的正则表达式如何写?
本帖最后由 yz1311 于 2013-10-09 22:06:11 编辑
  <tr><td class="name">救世主2 出租车司机DVD</td><td class="size">262.14 kb</td><td class="date">Oct  3, 2013</td><td class="action"><a href="/information/F15A1E4F33CBA648BACFA6A6AF79184A6A10C848" title="救世主2 出租车司机DVD" rel="information">Detail</a><a href="magnet:?xt=urn:btih:F15A1E4F33CBA648BACFA6A6AF79184A6A10C848&dn=%E6%95%91%E4%B8%96%E4%B8%BB2+%E5%87%BA%E7%A7%9F%E8%BD%A6%E5%8F%B8%E6%9C%BADVD&tr=http%3A%2F%2Ftracker.ktxp.com%3A6868%2Fannounce&tr=http%3A%2F%2Ftracker.ktxp.com%3A7070%2Fannounce&tr=udp%3A%2F%2Ftracker.ktxp.com%3A6868%2Fannounce&tr=udp%3A%2F%2Ftracker.ktxp.com%3A7070%2Fannounce&tr=http%3A%2F%2Fbtfans.3322.org%3A8000%2Fannounce&tr=http%3A%2F%2Fbtfans.3322.org%3A8080%2Fannounce&tr=http%3A%2F%2Fbtfans.3322.org%3A6969%2Fannounce&tr=http%3A%2F%2Ftracker.bittorrent.am%2Fannounce&tr=udp%3A%2F%2Ftracker.bitcomet.net%3A8080%2Fannounce&tr=http%3A%2F%2Ftk3.5qzone.net%3A8080%2F&tr=http%3A%2F%2Ftracker.btzero.net%3A8080%2Fannounce&tr=http%3A%2F%2Fscubt.wjl.cn%3A8080%2Fannounce&tr=http%3A%2F%2Fbt.popgo.net%3A7456%2Fannounce&tr=http%3A%2F%2Fthetracker.org%2Fannounce&tr=http%3A%2F%2Ftracker.prq.to%2Fannounce&tr=http%3A%2F%2Ftracker.publicbt.com%2Fannounce&tr=http%3A%2F%2Ftracker.dmhy.org%3A8000%2Fannounce&tr=http%3A%2F%2Fbt.titapark.com%3A2710%2Fannounce&tr=http%3A%2F%2Ftracker.tjgame.enorth.com.cn%3A8000%2Fannounce&" title="救世主2 出租车司机DVD" rel="magnet">Open</a><a href="http://www.torrentkitty.com/torrent/1306124/救世主2 出租车司机DVD" style="display:hidden;"></a></td></tr>


        <tr><td class="name">救世主#圣城家园$圣城孤少</td><td class="size">50.84 kb</td><td class="date">Jul 22, 2013</td><td class="action"><a href="/information/8585BC7C9FCCA58FBA26ED3E7BF7417FD1E42A14" title="救世主#圣城家园$圣城孤少" rel="information">Detail</a><a href="magnet:?xt=urn:btih:8585BC7C9FCCA58FBA26ED3E7BF7417FD1E42A14&dn=%E6%95%91%E4%B8%96%E4%B8%BB%23%E5%9C%A3%E5%9F%8E%E5%AE%B6%E5%9B%AD%24%E5%9C%A3%E5%9F%8E%E5%AD%A4%E5%B0%91&tr=http%3A%2F%2Ftracker.ktxp.com%3A6868%2Fannounce&tr=http%3A%2F%2Ftracker.ktxp.com%3A7070%2Fannounce&tr=udp%3A%2F%2Ftracker.ktxp.com%3A6868%2Fannounce&tr=udp%3A%2F%2Ftracker.ktxp.com%3A7070%2Fannounce&tr=http%3A%2F%2Fbtfans.3322.org%3A8000%2Fannounce&tr=http%3A%2F%2Fbtfans.3322.org%3A8080%2Fannounce&tr=http%3A%2F%2Fbtfans.3322.org%3A6969%2Fannounce&tr=http%3A%2F%2Ftracker.bittorrent.am%2Fannounce&tr=udp%3A%2F%2Ftracker.bitcomet.net%3A8080%2Fannounce&tr=http%3A%2F%2Ftk3.5qzone.net%3A8080%2F&tr=http%3A%2F%2Ftracker.btzero.net%3A8080%2Fannounce&tr=http%3A%2F%2Fscubt.wjl.cn%3A8080%2Fannounce&tr=http%3A%2F%2Fbt.popgo.net%3A7456%2Fannounce&tr=http%3A%2F%2Fthetracker.org%2Fannounce&tr=http%3A%2F%2Ftracker.prq.to%2Fannounce&tr=http%3A%2F%2Ftracker.publicbt.com%2Fannounce&tr=http%3A%2F%2Ftracker.dmhy.org%3A8000%2Fannounce&tr=http%3A%2F%2Fbt.titapark.com%3A2710%2Fannounce&tr=http%3A%2F%2Ftracker.tjgame.enorth.com.cn%3A8000%2Fannounce&" title="救世主#圣城家园$圣城孤少" rel="magnet">Open</a><a href="http://www.torrentkitty.com/torrent/1096239/救世主#圣城家园$圣城孤少" style="display:hidden;"></a></td></tr>


上面是HTML代码的一部分,只需要提取magnet:?开始到后面引号之间的整个磁力链接
例如:
<a href="magnet:?xt=urn:btih:F15A1E4F33CBA648BACFA6A6AF79184A6A10C848&dn=%E6%95%91%E4%B8%96%E4%B8%BB2+%E5%87%BA%E7%A7%9F%E8%BD%A6%E5%8F%B8%