Интерактивный плагин Nutch Selenium игнорирует конфигурацию chromedriver

#selenium #solr #selenium-chromedriver #nutch

#selenium #solr #selenium-chromedriver #nutch

Вопрос:

Я настроил nutch-site.xml для локального обхода с включенным плагином selenium interactive.

Я настроил только основы, поэтому конфигурация довольно проста (свойства из conf/nutch-site.xml ).

 <property>
  <name>plugin.includes</name>
  <value>protocol-interactiveselenium|urlfilter-(regex|validator)|parse-(html|tika)|index-(basic|anchor)|indexer-solr|scoring-opic|urlnormalizer-(pass|regex|basic)</value>
  <description>Regular expression naming plugin directory names to
  include.  Any plugin not matching this expression is excluded.
  By default Nutch includes plugins to crawl HTML and various other
  document formats via HTTP/HTTPS and indexing the crawled content
  into Solr.  More plugins are available to support more indexing
  backends, to fetch ftp:// and file:// URLs, for focused crawling,
  and many other use cases.
  </description>
</property>

<property>
  <name>selenium.driver</name>
  <value>chrome</value>
  <description>
    A String value representing the flavour of Selenium
    WebDriver() to use. Currently the following options
    exist - 'firefox', 'chrome', 'safari', 'opera' and 'remote'.
    If 'remote' is used it is essential to also set correct properties for
    'selenium.hub.port', 'selenium.hub.path', 'selenium.hub.host',
    'selenium.hub.protocol', 'selenium.grid.driver', 'selenium.grid.binary'
    and 'selenium.enable.headless'.
  </description>
</property>

<property>
  <name>webdriver.chrome.driver</name>
  <value>/Users/theo/DISKS/Work/PNR/chromedriver</value>
  <description>The path to the ChromeDriver binary</description>
</property>
  

Это из журналов nutch:

 2020-08-17 23:40:57,427 ERROR interactiveselenium.Http - Failed to get protocol output
java.lang.RuntimeException: java.lang.IllegalStateException: The driver executable does not exist: /root/chromedriver
        at org.apache.nutch.protocol.selenium.HttpWebClient.getDriverForPage(HttpWebClient.java:153)
        at org.apache.nutch.protocol.interactiveselenium.HttpResponse.readPlainContent(HttpResponse.java:401)
        at org.apache.nutch.protocol.interactiveselenium.HttpResponse.<init>(HttpResponse.java:280)
        at org.apache.nutch.protocol.interactiveselenium.Http.getResponse(Http.java:57)
        at org.apache.nutch.protocol.http.api.HttpBase.getProtocolOutput(HttpBase.java:383)
        at org.apache.nutch.fetcher.FetcherThread.run(FetcherThread.java:352)
Caused by: java.lang.IllegalStateException: The driver executable does not exist: /root/chromedriver
        at com.google.common.base.Preconditions.checkState(Preconditions.java:585)
        at org.openqa.selenium.remote.service.DriverService.checkExecutable(DriverService.java:146)
        at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:141)
        at org.openqa.selenium.chrome.ChromeDriverService.access$000(ChromeDriverService.java:35)
        at org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:159)
        at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:355)
        at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:94)
        at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:157)
        at org.apache.nutch.protocol.selenium.HttpWebClient.createChromeWebDriver(HttpWebClient.java:182)
        at org.apache.nutch.protocol.selenium.HttpWebClient.getDriverForPage(HttpWebClient.java:89)
        ... 5 more
2020-08-17 23:40:57,430 INFO  fetcher.FetcherThread - FetcherThread 46 fetch of https://www.amazon.in/ failed with: java.lang.RuntimeException: java.lang.IllegalStateException: The driver executable does not exist: /root/chromedriver
  

Почему он ищет не в том месте?

На самом деле.. он ссылается на другие настройки из nutch-site.xml правильно. Как только я включил протокол-interactiveselenium, он начал использовать selenium для выборки.

Кроме того, ранее он искал /root / geckodriver, который является драйвером firefox. Как только я изменил selenium.driver на chrome, он начал искать / root / chromedriver.

Итак, пока все хорошо. Теперь я пошел и изменил свойство webdriver.chrome.driver, но, похоже, это не учитывается.

Комментарии:

1. @SebastianNagel Спасибо. Кажется, он рассматривает «selenium.grid.binary», даже если он не запущен в удаленном режиме.

2. Спасибо за подтверждение. Проблема отслеживается как NUTCH-2825 .

Ответ №1:

Просматриваем код HttpWebClient — свойство webdriver.chrome.driver перезаписывается значением selenium.grid.binary . Указание последнего на ваш chromedrive должно сработать. Пожалуйста, откройте проблему на https://issues.apache.org/jira/projects/NUTCH , неясно, является ли это ошибкой или проблемой с документацией. Но в любом случае его следует устранить.