1

자바 스크립트 사용 웹 사이트에서 다른 제품의 이름과 가격을 구문 분석하기 위해 스플래쉬 스플래시로 작업 한 것은 이번이 처음입니다. 스크립트에서 사용한 셀렉터는 완벽합니다. 셀렌을 사용하여 이미 테스트했습니다. 그러나 스크립트를 실행하면 아래와 같은 오류가 발생합니다. 내 스파이더 컬렉션의 전체 상태 인 로그 파일을 첨부했습니다. 내 스파이더를 성공적으로 수행하기 위해해야 ​​할 일이 있습니까? 미리 감사드립니다. 여기 내 스파이더가 스플래시와 함께 실행되도록 만들 수 없습니다.

는 스크립트입니다

나는 settings.py에 추가 한 어떤
import scrapy 
from scrapy_splash import SplashRequest 

class RedmartSpider(scrapy.Spider): 
    name = 'redmart' 
    start_urls = ['https://redmart.com/bakery',] 

    def start_requests(self): 
    for url in self.start_urls: 
     yield SplashRequest(url, self.parse, args={'wait': 0.5}) 

    def parse(self, response): 
    for item in response.css(".productDescriptionAndPrice"): 
     name = item.css("h4 a::text").extract_first() 
     price = item.css("[itemprop=price]::text").extract_first() 
     yield {"Name":name,"Price":price} 

:

SPLASH_URL = 'http://192.168.59.103:8050' 
DOWNLOADER_MIDDLEWARES = { 
    'scrapy_splash.SplashCookiesMiddleware': 723, 
    'scrapy_splash.SplashMiddleware': 725, 
    'scrapy.downloadermiddlewares.httpcompression.HttpCompressionMiddleware': 810, 
} 
SPIDER_MIDDLEWARES = { 
    'scrapy_splash.SplashDeduplicateArgsMiddleware': 100, 
} 

이 부분 오류 로그입니다 :

Traceback (most recent call last): 
    File "c:\users\ar\appdata\local\programs\python\python35-32\lib\site-packages\twisted\internet\defer.py", line 1384, in _inlineCallbacks 
    result = result.throwExceptionIntoGenerator(g) 
    File "c:\users\ar\appdata\local\programs\python\python35-32\lib\site-packages\twisted\python\failure.py", line 393, in throwExceptionIntoGenerator 
    return g.throw(self.type, self.value, self.tb) 
    File "c:\users\ar\appdata\local\programs\python\python35-32\lib\site-packages\scrapy\core\downloader\middleware.py", line 43, in process_request 
    defer.returnValue((yield download_func(request=request,spider=spider))) 
twisted.internet.error.TCPTimedOutError: TCP connection timed out: 10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.. 

이것은 link입니다 로그 파일에 저장하십시오.

답변

0

SPLASH_URL이 잘못되었을 수 있습니다.이 IP는 문서 용 예제로 사용 된 것과 동일합니다.

docker run -p 8050:8050 scrapinghub/splash으로 스플래시 컨테이너를 실행중인 경우 SPLASH_URLhttp://localhost:8050이어야합니다.

관련 문제