我有一个http://www.statistics.com/index.php?page=glossary&term_id=703
具体在这些部分:
<b>Additive Error:</b>
<p> Additive error is the error that is added to the true value and does not
depend on the true value itself. In other words, the result of the measurement is
considered as a sum of the true value and the additive error: </p>
我尽我所能获取标签<p>
和之间的文本</p>
,用这个:
include('simple_html_dom.php');
$url = 'http://www.statistics.com/index.php?page=glossary&term_id=703';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$curl_scraped_page = curl_exec($ch);
$html = new simple_html_dom();
$html->load($curl_scraped_page);
foreach ( $html->find('b') as $e ) {
echo $e->innertext . '<br>';
}
它给了我:
Additive Error:
Browse Other Glossary Entries
我试图将 foreach 更改为:foreach ( $html->find('b p') as $e ) {
然后foreach ( $html->find('/b p') as $e ) {
然后它一直只给我空白页。我做错了什么?谢谢。