【发布时间】:2013-11-25 18:18:46
【问题描述】:
我正在尝试从使用 PHP CURL 检索的 html 源访问 H1 标记。
HTML:http://pastebin.com/4ubAhS3E
我正在尝试访问最后一行(第 63 行):<h1>Your referrals (5 complete / 0 pending / 9999 total)</h1>
这是php simple html dom正在使用的部分代码
$result1 = curl_exec ($ch1);
curl_close($ch1);
echo $result1;
$html = str_get_html($result1);
$main = $html->find('h1', 3);
foreach($main as $element)
echo $element->innertext . '<br>';
但它只是带回了整个 HTML
【问题讨论】:
-
->find()仅在您未指定第二个参数时才返回一个数组。如果你这样做,它会返回一个 dom 节点。