Reputation: 339
been trying to get scrapy-selenium to work for a while, I have the simple code from the tutorial and just trying to take a screenshot but for some reason I don't get a proper response, here is my code:
from shutil import which
SELENIUM_DRIVER_NAME = 'firefox'
SELENIUM_DRIVER_EXECUTABLE_PATH = which('geckodriver')
SELENIUM_DRIVER_ARGUMENTS=['-headless'] # '--headless' if
using chrome instead of firefox
DOWNLOADER_MIDDLEWARES = {
'scrapy_selenium.SeleniumMiddleware': 800
}
from scrapy_selenium import SeleniumRequest
def start():
yield SeleniumRequest(
url='www.google.com',
callback=parse_result, wait_time=1000,
screenshot=True
)
def parse_result(self, response):
print(response.meta)
with open('image.png', 'wb') as image_file:
image_file.write(response.meta['screenshot'])
start()
I am getting no screenshot key in response.meta.. what am I missing ? by the way I am using python 3.10 Thanks in advance :)
Upvotes: 1
Views: 209