Goutte无法点击链接

时间:2015-05-20 10:51:35

标签: php string string-comparison goutte

我不确定这里发生了什么,我正在使用Goutte进行爬网,尝试抓取exploitdb上的所有漏洞,但显然我无法点击1个特定链接。这是代码:

<?php

    require_once 'goutte.phar';

     use Goutte\Client;

     $client = new Client();

function crawler_metasploit(){


          global $client;


          $crawler = $client->request('GET','https://www.exploit-db.com/search/?order_by=date&order=desc&pg=1&action=search');


          $exploits =  $crawler->filterXPath('//table[@class="exploit_list bootstrap-wrapper"]//tr[position()=14]/
                                             td[@class="description"]/a[@href]')->each(function ($nodes) {
                     return  $nodes->text();
                         });


          foreach ($exploits as $exploit){

            //$exploit = trim(preg_replace("/[\r\n]+/", " ", $exploit));

            print "<p>".$exploit."</p>";

            if ($exploit == 'VideoCharge Express 3.16.3.04 - BOF Exploit'){

                print 'same';

            }
          else {

            print '<p>diff</p>';
            print '<p>VideoCharge Express 3.16.3.04 - BOF Exploit</p>';
            print $exploit;
          }

            $crawler2 = $client->click($crawler->selectLink($exploit)->link());



                      $code = $crawler2->filterXPath('//table[@class="exploit_list"]//tr[position()=1]/td[position()=2]/a')->each(function ($nodes) {
                     return  $nodes->text();
                         });



          print "<p>".$code[0]."</p>";

          if ($code[0] != ""){

            print "there is cve";

          }

            print 'hi';

      } 







     }

     crawler_metasploit();
?>

输出是&#34; diff&#34;,显然字符串与我直接从网站上复制粘贴时的字符串相同,但不是,只有这个特定的字符串发生,我用过这个功能也是:

$exploit = trim(preg_replace("/[\r\n]+/", " ", $exploit));

但没有成功。

可能会发生什么?

0 个答案:

没有答案