【问题标题】:using crawler4j for html file on file system在文件系统上使用 crawler4j 获取 html 文件
【发布时间】:2012-12-26 06:50:42
【问题描述】:

我正在尝试使用 edu.uci.ics.crawler4j lib 从本地目录中的 html 文件中抓取页面。 C:/work/temp/test.html 是它的路径。

我发现 crawler4j 正在建立 Http 连接。但是对于这种情况,不需要 Http 连接。我还在文件路径前面加上了file://,比如"file:///C:/work/temp/test.html" (which is accessible)

来自PageFetcher类的代码:

    SchemeRegistry schemeRegistry = new SchemeRegistry();
    schemeRegistry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));

    if (config.isIncludeHttpsPages()) {
        schemeRegistry.register(new Scheme("https", 443, SSLSocketFactory.getSocketFactory()));
    }

有没有办法在 crawler4j 的 PageFetcher 中的 SchemeRegistry 中注册 file:// 协议或 crawler4j 总是用于服务器上的托管文件?

【问题讨论】:

    标签: java web-crawler


    【解决方案1】:

    它应该是您的本地主机 URL。例如,localhost:80/ 应该是您目录的根目录。 URL 应该类似于 http://localhost:80/.......

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-01-06
      • 1970-01-01
      • 1970-01-01
      • 2013-03-19
      • 2022-06-20
      • 2018-11-07
      • 2015-09-23
      • 2017-09-22
      相关资源
      最近更新 更多