def download_torrent(url):
fname = os.getcwd() + '/' + url.split('title=')[-1] + '.torrent'
try:
schema = ('http:')
r = requests.get(schema + url, stream=True)
with open(fname, 'wb') as f:
for chunk in r.iter_content(chunk_size=1024):
if chunk:
f.write(chunk)
f.flush()
except requests.exceptions.RequestException as e:
print('\n' + OutColors.LR + str(e))
sys.exit(1)
return fname
在这段代码中,当我运行完整的脚本时,我得到一个错误。当我去下载torrent时,我得到:('Connection aborted.', BadStatusLine("''",))
我只发布了我认为与上面相关的代码块。整个脚本如下。这是从长裤,但我认为它不再保持,我正试图让它运行与Python3。从我的研究来看,这个错误可能意味着我使用的是http而不是https,但我已经尝试了两者。