|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
import urllib.request
import re
import random
def open_url(url):
req = urllib.request.Request(url)
req.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36')
proxies = ['171.214.248.246:8118', '123.130.11.82:8118', '42.55.174.146:80']
proxy = random.choice(proxies)
proxy_support = urllib.request.ProxyHandler({'http':proxy})
opener = urllib.request.build_opener(proxy_support)
urllib.request.install_opener(opener)
response = urllib.request.urlopen(req)
html = response.read()
return html
def get_magnet(html):
p = r'<a href="(.+)" title=".+" rel="magnet">'
result = re.findall(p,html)
for each in result:
print(each)
if __name__ == '__main__':
fh = input('Please enter the FH:')
url = 'https://www.torrentkitty.tv/search/' +fh
get_magnet(open_url(url))
- import urllib.request
- import re
- from urllib import parse
- def open_url(url):
- req = urllib.request.Request(url)
- req.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36')
- response = urllib.request.urlopen(req)
- html = response.read().decode('utf-8')
- return html
- def get_magnet(html):
- p = r'<a href="(magnet:\?xt=urn:btih:[^"]+)'
- result = re.findall(p,html)
- for each in result:
- print(each)
- if __name__ == '__main__':
- fh = input('Please enter the FH:')
- url = 'https://www.torrentkitty.tv/search/' + parse.quote(fh)+'/'
- get_magnet(open_url(url))
复制代码
|
|