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
在該代碼塊中,當我運行完整腳本時出現錯誤。當我去到實際下載種子,我得到:Python請求獲取('Connection aborted。',BadStatusLine(「''」,))錯誤
('Connection aborted.', BadStatusLine("''",))
我只貼的代碼,我認爲相關的上述塊。整個腳本在下面。它來自於pantuts,但我不認爲它已經保存了,我試圖用python3來運行它。從我的研究中,錯誤可能意味着我使用http而不是https,但我已經嘗試了兩種。
你可以提供一個示例url在哪裏發生? – TobiMarg
您粘貼的代碼缺少'try'。我得到了一個不同的錯誤:'('連接中止。',RemoteDisconnected('無響應的遠端關閉連接'))'希望有一個更具描述性的錯誤可以幫助你。 – sorbet
hmm。運行時腳本不給我的網址只是洪流的名字,所以我不能發佈一個示例url。我剛剛搜索了學習python並選擇了第一個洪流。我不確定你錯過了什麼意思。你能詳細說明嗎?謝謝你的幫助。 – eurabilis