Python 刮痧虫
蜘蛛网: 问题:使用scrapy.RequestAll ok,但在splash.png中我看到的是这个,而不是Google页面截图。你的请求怎么了Python 刮痧虫,python,scrapy,python-3.6,scrapy-splash,Python,Scrapy,Python 3.6,Scrapy Splash,蜘蛛网: 问题:使用scrapy.RequestAll ok,但在splash.png中我看到的是这个,而不是Google页面截图。你的请求怎么了 补充我用Python 3.4.2、Scrapy 1.4.0、Scrapy_splash 0.7.2测试了你的代码,它对我很有用。您是否在settings.py中添加了所有信息(如中)?我也遇到了同样的问题。但后来我注意到,这不仅仅是图像如何处理的问题,还有scrapy如何处理飞溅响应的问题。Splash本身运行良好(通过浏览器和curl),但不是s
补充我用Python 3.4.2、Scrapy 1.4.0、Scrapy_splash 0.7.2测试了你的代码,它对我很有用。您是否在settings.py中添加了所有信息(如中)?我也遇到了同样的问题。但后来我注意到,这不仅仅是图像如何处理的问题,还有scrapy如何处理飞溅响应的问题。Splash本身运行良好(通过浏览器和curl),但不是scrapy…可能的答案(不是我的,我也不尝试)添加到问题中我用Python 3.4.2、scrapy 1.4.0、scrapy_Splash 0.7.2测试了您的代码,它对我很有效。您是否在settings.py中添加了所有信息(如中)?我也遇到了同样的问题。但后来我注意到,这不仅仅是图像如何处理的问题,还有scrapy如何处理飞溅响应的问题。Splash本身运行良好(通过浏览器和卷曲),但不能使用scrapy…问题中添加了可能的答案(不是我的,我也不尝试)
import scrapy
from scrapy_splash import SplashRequest
class TestSpider(scrapy.Spider):
name = 'test'
def start_requests(self):
splash_args = {
'png': 1,
'render_all': 1,
'wait': 2,
}
url = 'https://google.com'
yield SplashRequest(
url,
callback=self.parse_splash,
endpoint='render.png',
args=splash_args
)
yield scrapy.Request(
f"http://localhost:8050/render.png?url={url}&wait=2&render_all=1",
self.parse_request,
)
def parse_request(self, response):
with open('request.png', 'wb') as f:
f.write(response.body)
def parse_splash(self, response):
with open('splash.png', 'wb') as f:
f.write(response.body)