Dies ist mein erstes Mal mit scrapy-splash zu arbeiten, um den Namen und Preis verschiedener Produkte von einer javascript-fähigen Website zu analysieren. Die Selektoren, die ich in meinem Skript verwendet habe, sind makellos, was ich bereits mit Selen getestet habe. Wenn ich jedoch mein Skript ausführe, wird unten ein Fehler angezeigt. Ich habe eine Protokolldatei angehängt, die den Gesamtstatus meiner Spider-Sammlung darstellt. Gibt es noch etwas, was ich für die erfolgreiche Ausführung meiner Spinne tun muss? Danke im Voraus. HierIch kann meine Spinne nicht in Kombination mit Splash schreiben
ist das Skript:
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}
Was ich zum settings.py
hinzugefügt haben:
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,
}
Dies ist das Teilfehlerprotokoll:
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..
Dies ist link in die Protokolldatei.