python requests请求终止,Python请求获取('连接中止',BadStatusLine('',))

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,但我已经尝试了两者。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值