<i id='EWFLf'><tr id='EWFLf'><dt id='EWFLf'><q id='EWFLf'><span id='EWFLf'><b id='EWFLf'><form id='EWFLf'><ins id='EWFLf'></ins><ul id='EWFLf'></ul><sub id='EWFLf'></sub></form><legend id='EWFLf'></legend><bdo id='EWFLf'><pre id='EWFLf'><center id='EWFLf'></center></pre></bdo></b><th id='EWFLf'></th></span></q></dt></tr></i><div id='EWFLf'><tfoot id='EWFLf'></tfoot><dl id='EWFLf'><fieldset id='EWFLf'></fieldset></dl></div>

<small id='EWFLf'></small><noframes id='EWFLf'>

    <bdo id='EWFLf'></bdo><ul id='EWFLf'></ul>
    <tfoot id='EWFLf'></tfoot>
      1. <legend id='EWFLf'><style id='EWFLf'><dir id='EWFLf'><q id='EWFLf'></q></dir></style></legend>

        CasperJS/PhantomJS 分段错误

        时间:2023-05-28
        <i id='3jROL'><tr id='3jROL'><dt id='3jROL'><q id='3jROL'><span id='3jROL'><b id='3jROL'><form id='3jROL'><ins id='3jROL'></ins><ul id='3jROL'></ul><sub id='3jROL'></sub></form><legend id='3jROL'></legend><bdo id='3jROL'><pre id='3jROL'><center id='3jROL'></center></pre></bdo></b><th id='3jROL'></th></span></q></dt></tr></i><div id='3jROL'><tfoot id='3jROL'></tfoot><dl id='3jROL'><fieldset id='3jROL'></fieldset></dl></div>
          <tfoot id='3jROL'></tfoot>

          1. <legend id='3jROL'><style id='3jROL'><dir id='3jROL'><q id='3jROL'></q></dir></style></legend>

            <small id='3jROL'></small><noframes id='3jROL'>

                  <tbody id='3jROL'></tbody>

                  <bdo id='3jROL'></bdo><ul id='3jROL'></ul>
                  本文介绍了CasperJS/PhantomJS 分段错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我有一个脚本可以打开链接数组中的 url,并且对于每个 url,它会提取该 url 中的链接并将新链接插入到数组链接(addLinks 函数).该代码导致分段错误,并且当它调用 this.start 打开一个有效的 url(代码的第 3 行)时会发生这种情况.是 casperjs 还是我的代码有问题?

                  另一个有趣的点是它总是在页面标题:"之后打印OK,它已加载",而根据代码,它们应该以相反的顺序打印.你能告诉我这种奇怪行为的原因吗?

                  //只是打开页面并打印标题功能开始(链接){this.echo('让我们试试链接:-- '+ 链接 + ' -------------');this.start(链接,函数(){this.echo('页面标题:' + this.getTitle());});this.echo('OK,加载完毕
                  ');}功能检查(){if (links[currentLink] && currentLink < upTo) {this.echo('--- 链接 ' + currentLink + ' ---');start.call(this, links[currentLink]);addLinks.call(this, links[currentLink]);当前链接++;this.run(检查);} 别的 {this.echo("全部完成.");this.exit();}}casper.start().then(function() {this.echo("开始");});casper.run(检查);

                  这是我的代码的结果:

                  <上一页>--- 链接 0 ---让我们试试链接:-- http://yahoo.com -------------好的,已加载页面标题:雅虎找到 111 个链接 http://yahoo.com找到 13 个脚本 http://yahoo.com找到 0 帧 http://yahoo.com帧源:新框架源:--- 链接 1 ---让我们试试链接:-- http://everything.yahoo.com/-------------好的,已加载PhantomJS 崩溃了.请阅读崩溃报告指南...分段错误(核心转储)

                  解决方案

                  casper.startcasper.run 只在你的 once 中使用脚本.您可以将 this.start 重命名为 this.thenOpen 并将 this.run 重命名为 this.then.

                  I have a script which opens the urls in the links array and for each url it extracts the links in that url and inserts the new links to the array links(addLinks function). The code results in segmentation fault and it happens when it calls this.start to open a valid url (3rd line of the code). Is it a problem with casperjs or my code?

                  Another interesting point is that it always prints 'OK, it is loaded' after the 'Page title: ' while according to the code they should be printed in reverse order. Would you please tell me the reason for this strange behaviour?

                  // Just opens the page and prints the title
                  function start(link) {
                      this.echo('lets try the link:--  '+ link + ' -------------');
                      this.start(link, function() {
                          this.echo('Page title: ' + this.getTitle());
                      });
                      this.echo('OK, it is loaded
                  ');
                  }
                  
                  function check() {
                      if (links[currentLink] && currentLink < upTo) {
                          this.echo('--- Link ' + currentLink + ' ---');
                          start.call(this, links[currentLink]);
                          addLinks.call(this, links[currentLink]);
                          currentLink++;
                          this.run(check);
                      } else {
                          this.echo("All done.");
                          this.exit();
                      }
                  }
                  casper.start().then(function() {
                      this.echo("Starting");
                  });
                  
                  casper.run(check);
                  

                  Here is the result of my code:

                  --- Link 0 ---
                  lets try the link:--  http://yahoo.com -------------
                  OK, it is loaded
                  
                  Page title: Yahoo
                  111 links found http://yahoo.com
                  13 scripts found http://yahoo.com
                  0 frames found http://yahoo.com
                   frame src:
                  new frame src:
                  --- Link 1 ---
                  lets try the link:--  http://everything.yahoo.com/ -------------
                  OK, it is loaded
                  
                  PhantomJS has crashed. Please read the crash reporting guide...
                  Segmentation fault (core dumped)
                  

                  解决方案

                  Use casper.start and casper.run only once in your script. You can rename this.start to this.thenOpen and this.run to this.then.

                  这篇关于CasperJS/PhantomJS 分段错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Gulp:如何设置相对于已处理文件的目标文件夹(使 下一篇:libGDX HTML5 部署异常

                  相关文章

                  最新文章

                • <legend id='ozmLi'><style id='ozmLi'><dir id='ozmLi'><q id='ozmLi'></q></dir></style></legend>
                  <tfoot id='ozmLi'></tfoot>

                  1. <small id='ozmLi'></small><noframes id='ozmLi'>

                    • <bdo id='ozmLi'></bdo><ul id='ozmLi'></ul>
                    <i id='ozmLi'><tr id='ozmLi'><dt id='ozmLi'><q id='ozmLi'><span id='ozmLi'><b id='ozmLi'><form id='ozmLi'><ins id='ozmLi'></ins><ul id='ozmLi'></ul><sub id='ozmLi'></sub></form><legend id='ozmLi'></legend><bdo id='ozmLi'><pre id='ozmLi'><center id='ozmLi'></center></pre></bdo></b><th id='ozmLi'></th></span></q></dt></tr></i><div id='ozmLi'><tfoot id='ozmLi'></tfoot><dl id='ozmLi'><fieldset id='ozmLi'></fieldset></dl></div>