用番号搜索磁力连接

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

#!/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])