用番号搜索磁力连接

2014-11-18 0 1,003
用番号搜索磁力连接
#!/usr/bin/env python
#coding=utf8

import sys
import urllib2
import re

def query_magnet(key):
    try:

        #response是HTTPResponse对象
        response = urllib2.urlopen('http://www.btants.cc/q?kw=%s'%(key), timeout=20)
        restr=re.compile(r'''<a(\s*)(.*?)(\s*)href(\s*)=(\s*)([\"\s]*)([^\"\']+?)([\"\s]+)(.*?)>''')
        html=response.read()
        href_list=re.findall(restr,html)
        for href_tup in href_list:
            for href in href_tup:
                if href.find("magnet:?")!=-1:
                    print href
    except Exception, e:
        print e

if __name__=="__main__":
    query_magnet(sys.argv[1])

遇见资源网 python 用番号搜索磁力连接 http://www.ox520.com/14899.html

Python 解析 html
上一篇: Python 解析 html
使用C++扩展python
下一篇: 使用C++扩展python
常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务