Я не получаю никакого результата для следующего запроса xpath
$url="https://example.com";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
$html = curl_exec($ch);
curl_close($ch);
/* Use internal libxml errors -- turn on in production, off for debugging */
libxml_use_internal_errors(true);
/* Createa a new DomDocument object */
$dom = new DomDocument;
/* Load the HTML */
@$dom->loadHTMLFile($html);
/* Create a new XPath object */
$xpath = new DomXPath($dom);
/* Query all <td> nodes containing specified class name */
$nodes = $xpath->query('//img[@class="info_flag"]/@alt');
/* Traverse the DOMNodeList object to output each DomNode's nodeValue */
foreach ($nodes as $node) {
echo $node."\n";
}
, пока выполняется print_r, он выводит нулевой массив.я использовал пользовательский агент в качестве блокировки удаленного сайта с 403.