不能用PHP简单的HTML DOM解析器解析网页

不能用PHP简单的HTML DOM解析器解析网页

问题描述:

我使用下面的代码,但是从链接我不能解析所有库存数据的值。可以有人帮我吗?

I use below code but from the link i can't Parser value of all stock data. Can any one help me please?

<?php
// Include the library
include('simple_html_dom.php');

// Retrieve the DOM from a given URL
$html = file_get_html('http://www.dsebd.org/dseX_share.php');


// Extract all text from a given cell
echo $html->find('td[align="center"]', 1)->plaintext.'<br><hr>';


<?php

ini_set('display_errors', 1);
include_once('simple_html_dom.php');

$html = file_get_html('http://www.dsebd.org/dseX_share.php');
$table = $html->find('table', 5);

$rowData = array();

foreach ($table->find('tr') as $row)
{
    foreach ($row->find('td') as $cell)
    {
        $flight = array();
        $cell->plaintext=  preg_replace('/<\/[\w]+>/',"",$cell->plaintext);
        $flight[] = array_map('trim', preg_split("@(\&nbsp;)+@", $cell->plaintext));
    }
    $rowData=array_merge($rowData,$flight);
}
print '<pre>';
print_r($rowData);
print '</pre>';
?>