在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問(wèn)答/人工智能  Java  Python/ 爬蟲(chóng)發(fā)出ajax請(qǐng)求,requests能獲取正常響應(yīng),scrapy發(fā)出請(qǐng)求卻返回

爬蟲(chóng)發(fā)出ajax請(qǐng)求,requests能獲取正常響應(yīng),scrapy發(fā)出請(qǐng)求卻返回400

我爬取一個(gè)網(wǎng)站,數(shù)據(jù)是要向服務(wù)器發(fā)出異步請(qǐng)求加載帶,我仿造headers,參數(shù)都沒(méi)有錯(cuò)誤,用requests能獲取正常響應(yīng),當(dāng)scrapy不行

    def parse_histical_data(self, response):
        html = BeautifulSoup(response.body, 'lxml')
        patterm = re.compile(r'smlId: [0-9]*', re.MULTILINE|re.UNICODE)
        script = html.find('script', text=patterm).text
        smlId_text = patterm.search(script).group()
        smlId = smlId_text.split(' ')[1]
        curr_id = response.meta['pair_id']
        header=html.select('#leftColumn > div.instrumentHeader > h2')[0].string
        st_date = '01/01/2001'
        end_date = '05/07/2050'
        interval_sec = 'Daily'
        sort_col = 'date'
        sort_ord = 'DESC'
        action = 'historical_data'
        data = {'smlID': smlId, 'curr_id': curr_id, 'header': header, 'st_date': st_date, 'end_state': end_date,
                'interval_sec': interval_sec, 'sort_col': sort_col, 'sort_ord': sort_ord, 'action': action}
        head = self.download_headers.copy()
        request = FormRequest(self.his_url, callback=self.parse_histical_data,
                              headers=head, formdata=data)
        yield request
        

請(qǐng)求帶網(wǎng)址是'https://www.investing.com/ins...',使用一模一樣帶headers和data,scrapy返回400

回答
編輯回答
溫衫

請(qǐng)求頭有錯(cuò)誤

2018年4月29日 23:07
編輯回答
絯孑氣

請(qǐng)問(wèn)樓主解決了嗎,遇同樣問(wèn)題,請(qǐng)問(wèn)咋解決呢

2017年7月9日 02:04