Goutte - 获取表格列包含引号

时间:2017-09-19 02:49:13

标签: tablecolumn goutte

我有这段代码:

require ('vendor/autoload.php');

use Goutte\Client;
use GuzzleHttp\Client as GuzzleClient;

$goutteClient = new Client();
$guzzleClient = new GuzzleClient(array(
    'timeout' => 6000,
));
$goutteClient->setClient($guzzleClient);

  $crawler = $goutteClient->request('GET', http://www.cophieu68.vn/stockonline_node.php?stcid=1);

  // Get the latest post in this category and display the titles
  $news = $crawler->filter('table#board_online>tbody>tr')->nextAll()->nextAll()->each(function ($node) {
    //  print_r($node->text());         
      return [              

          'v1' => $node->filter('td')->eq(0)->text(),   
          'v2' => $node->filter('td')->eq(1)->text(),   
          'v3' => $node->filter('td')->eq(2)->text(),                               
          'v12' => $node->filter('td')->eq(3)->text(),
          'v14' => $node->filter('td')->eq(4)->text(),
          'v16' => $node->filter('td')->eq(5)->text(),
          'v12' => $node->filter('td')->eq(6)->text(),
          'v13' => $node->filter('td')->eq(7)->text(),
          'v15' => $node->filter('td')->eq(8)->text(),
          'v16' => $node->filter('td')->eq(9)->text(),
          'v17' => $node->filter('td')->eq(10)->text(),
          'v18' => $node->filter('td')->eq(11)->text(),

      ];
  });

    print_r($news);

显示消息:

致命错误:未捕获异常'InvalidArgumentException',消息'当前节点列表为空。在E:\ xampp \ htdocs \ cr \ vendor \ symfony \ dom-crawler \ Crawler.php:568堆栈跟踪:#0 E:\ xampp \ htdocs \ cr \ data_now.php(43):Symfony \ Component \ DomCrawler \ Crawler-> text()#1 E:\ xampp \ htdocs \ cr \ vendor \ symfony \ dom-crawler \ Crawler.php(371):{closure}(Object(Symfony \ Component \ DomCrawler \ Crawler),345) #2 E:\ xampp \ htdocs \ cr \ data_now.php(61):Symfony \ Component \ DomCrawler \ Crawler-> each(Object(Closure))#3 E:\ xampp \ htdocs \ cr \ data_now.php( 105):doCraw_old('https://firebase.google.com/docs/configure/ ...',1,'2017-09-19')#4 {main}抛出E:\ xampp \ htdocs \ cr \ vendor \ symfony \ dom-crawler \第568行的Crawler.php

我希望它返回数组,但是错误,请帮助我!

0 个答案:

没有答案