Scrapy Spider在本地有效,但在scrapinghub上无效

时间:2018-11-22 13:50:14

标签: python openssl scrapy twisted

我正在使用一个抓痒的蜘蛛向站点发送2个POST请求。 在我的本地计算机上,它可以正常工作,并且我收到2条回复。

但是在Scrapy Cloud(scrapinghub.com)上,我对每个请求都遇到相同的错误:

  

[scrapy.core.scraper]错误下载https://baca.ii.uj.edu.pl/p12018/testerka_gwt/problems>:   twisted.python.failure.Failure OpenSSL.SSL.Error:[('SSL例程,   'SSL23_GET_SERVER_HELLO','tlsv1警报内部错误')]>]

该站点的证书已过期,我认为这是引起问题的原因。但是草率的文档说,默认情况下未选中站点证书,所以我不知道。

我的蜘蛛码:

class resultsTest(scrapy.Spider):
    name = "results"

    custom_settings = {
        'ROBOTSTXT_OBEY': False,
    }

    def start_requests(self):
        firstAss = 4 #first assignment
        lastAss = 5 #last assignment
        url = 'https://baca.ii.uj.edu.pl/p12018/testerka_gwt/problems'
        bodyBeginning = '7|0|5|https://baca.ii.uj.edu.pl/p12018/testerka_gwt/|548F7E6329FFDEC9688CE48426651141|testerka.gwt.client.problems.ProblemsService|getProblemStatistic|I|1|2|3|4|1|5|'
        headers = {
                "Content-Type": "text/x-gwt-rpc; charset=UTF-8",
                "X-GWT-Module-Base": "https://baca.ii.uj.edu.pl/p12018/testerka_gwt/",
                "X-GWT-Permutation": "5A4AE95C27260DF45F17F9BF027335F6",
                }

        for num in range(firstAss, lastAss + 1):
            body = bodyBeginning + str(num) + "|" 
            yield scrapy.Request(
                    url,
                    method = "POST",
                    headers = headers,
                    body = body)

    def parse(self, response):
        yield response.body_as_unicode()

0 个答案:

没有答案