<?php
header("http-equiv: content-type;Content-type: text/html; charset=utf-8");
$url = 'http://www.hao6v.com/gvod/zx.html';
$outPageTxt = file_get_contents($url);
$dom = new DOMDocument();
@$dom->loadHTML($outPageTxt);
$dom->normalize();
$xpath = new DOMXPath($dom);
$data = $xpath->query('//*[@id="main"]/div[1]/div/ul/li/a');
//取值方式一
foreach ($data as $val) {
$item = $val->childNodes;
foreach ($item as $v) {
$str = trim($v -> textContent);
echo $str . '<br/>';
}
}
//取值方式二
for ($i = 0; $i < $data->length; $i++) {
$items = $data->item($i);
$text = $items->nodeValue;
echo $text . '<br/>';
}