我最近一直在与scrapy合作,我想拍摄一个网站的屏幕截图。我找到了这个:https://pypi.org/project/scrapy-selenium/,并认为可以利用它。我创建了这个文件:
from scrapy_selenium import SeleniumRequest
CHROME_PATH = '/usr/bin/google-chrome'
SELENIUM_DRIVER_EXECUTABLE_PATH = '/usr/bin/chromedriver'
SELENIUM_DRIVER_ARGUMENTS = "--headless"
DOWNLOADER_MIDDLEWARES = {
'scrapy_selenium.SeleniumMiddleware': 800
}
def main():
yield SeleniumRequest(
url='https://chainz.cryptoid.info/ltc/wallet.dws?1231.htm',
callback=parse_result,
screenshot=True
)
def parse_result(response):
with open('image.png', 'wb') as image_file:
image_file.write(response.meta['screenshot'])
main()
但是执行后我的目录中什么也没有出现。它不再受支持/损坏了,还是我缺少了什么?感谢您的提示。