403下载Archeve python 34

2024-05-23 14:03:06 发布

您现在位置:Python中文网/ 问答频道 /正文

我有个大问题!!我需要下载字幕存档,但我所有的努力都没有给我带来成功!!
1我已经用Scrapy登录了

class LoginSpider(scrapy.Spider):
name = 'opensubtitles.org'
start_urls = ['http://www.opensubtitles.org/ru/login/redirect-%7Cru']

def parse(self, response):
    return scrapy.FormRequest.from_response(
        response,
        formdata={'username': 'nothing_interesting_here', 'password': 'brute-force-me'},
        callback=self.after_login
    )

def after_login(self, response):
    # check login succeed before going on
    if "authentication failed" in response.body:
        self.logger.error("Login failed")
        return

2。在我试图下载文件,并有错误403禁止使用 urllib.request.urlretrieve如果我下载了超过15个文件,而python2只是url.retrive工作!!你知道吗

urllib.request.urlretrieve('http://dl.opensubtitles.org/en/download/sub/vrf-108d030f/6633065', 'NAMEEEEEEEEEEEE.zip')

我怎样才能解决这个问题?你知道吗


Tags: 文件orgselfhttpreturnresponserequestdef