【问题标题】:Meteor: The application is not spiderableMeteor:应用程序不可爬取
【发布时间】:2014-05-13 16:54:17
【问题描述】:

我的应用程序在本地和生产环境中都不可爬取。

当我转到http://localhost:3000/?_escaped_fragment_=时,我可以看到出现以下错误(幻影在15秒后被杀死):

spiderable: phantomjs failed: { [Error: Command failed: ] killed: true, code: null, signal: 'SIGTERM' }

似乎很多人都遇到了这个问题:

问题是我没有使用 observatory 或 select2 并且我的所有出版物都返回一个光标。据我说,问题来自于缩小。我刚刚读到in this thread 有人成功显示“SyntaxError: Parse error”。我如何才能更多地了解 Phantom 出了什么问题以及哪个文件导致了问题?

【问题讨论】:

    标签: meteor phantomjs


    【解决方案1】:

    如您链接的某些线程中所述,当可蜘蛛等待无法返回任何数据并最终超时的订阅时,就会发生这种情况。

    确保您的所有publish functions 要么返回一个游标、一个(可能为空的)游标列表,要么发送this.ready()。

    Meteor APM 可能有助于确定哪些出版物没有返回。

    【讨论】:

      【解决方案2】:

      如果您想了解更多关于 phatomjs 的问题,可以试试这个code (1):

      // Put your URL below, no "?_escaped_fragment_=" necessary
      var url = "http://your-url.com/";
      var page = require('webpage').create();
      page.open(url);
      setInterval(function() {
        var ready = page.evaluate(function () {
          if (typeof Meteor !== 'undefined'
              && typeof(Meteor.status) !== 'undefined'
              && Meteor.status().connected) {
            Deps.flush();
            return DDP._allSubscriptionsReady();
          }
          return false;
        });
        if (ready) {
          var out = page.content;
          out = out.replace(/<script[^>]+>(.|\n|\r)*?<\/script\s*>/ig, '');
          out = out.replace('<meta name=\"fragment\" content=\"!\">', '');
          console.log(out);
          phantom.exit();
        }
      }, 100);
      

      要在本地使用,请安装phantomjs。然后在您的应用程序之外,使用上面的代码创建一个文件phantomtest.js。并运行phantomjs phantomtest.js

      也许您可以尝试的另一件事是使用 UglifyJS 在缩小的 JS 文件中捕获一些错误,如 Payner35 did。

      【讨论】:

      • 谢谢,我已经尝试过了,但我的终端中没有出现任何内容。似乎 ready 是未定义的。
      【解决方案3】:

      我的问题来自 SSL。 You can have a complete overview of what I did here.

      编辑可爬取源并将--ignore-ssl-errors=yes 添加到 phantomjs 命令行,它将起作用。

      【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-12
      相关资源
      最近更新 更多