我正试着用刮擦网站。 但有重定向到404页错误,因为我不是来自那个国家。 如果使用代理,我有相同的。 我的代码:
# -*- coding: utf-8 -*-
import scrapy
from v4.items import Product
class AcerOfficeworksAuSpider(scrapy.Spider):
name = "acer_officeworks_au_py"
url = 'https://www.officeworks.com.au/shop/SearchDisplay?searchTerm=acer&storeId=10151&langId=-1&pageSize=24&beginIndex=0&sType=SimpleSearch&resultCatEntryType=2&showResultsPage=true&searchSource=Q&pageView='
def start_requests(self):
yield scrapy.Request(self.url, self.parse, meta={'proxy': 'http://97.77.104.22:3128'})
def parse(self, response):
print response
结果:
2017-03-23 12:49:29 [scrapy] DEBUG: Redirecting (302) to <GET https://wc-prod-joomla.s3.amazonaws.com/404/404.html> from <GET https://www.officeworks.com.au/shop/SearchDisplay?searchTerm=acer&storeId=10151&langId=-1&pageSize=24&beginIndex=0&sType=SimpleSearch&resultCatEntryType=2&showResultsPage=true&searchSource=Q&pageView=>
2017-03-23 12:49:34 [scrapy] DEBUG: Crawled (200) <GET https://wc-prod-joomla.s3.amazonaws.com/404/404.html> (referer: None)
<200 https://wc-prod-joomla.s3.amazonaws.com/404/404.html>
2017-03-23 12:49:34 [scrapy] INFO: Closing spider (finished)
响应,如果将curl与代理一起使用:
HTTP/1.1 200 Connection established
HTTP/1.1 302 Security Redirect
Cache-Control: no-cache
Expires: 0
Location: https://wc-prod-joomla.s3.amazonaws.com/404/404.html
Pragma: no-cache
transfer-encoding: chunked
Connection: keep-alive
我能做些什么来让它工作呢?你知道吗
产品数据位于以下url中:
这个页面使用JavaScript从上面的URL获取数据。你知道吗
相关问题 更多 >
编程相关推荐