带有XPath的PHP不';t返回hoster被替换的结果
我使用XPath创建了一个简单的PHP脚本,以从特定网站获取一些内容带有XPath的PHP不';t返回hoster被替换的结果,php,xpath,Php,Xpath,我使用XPath创建了一个简单的PHP脚本,以从特定网站获取一些内容 <?php $url = "http://www.weltfussball.de/spielbericht/bundesliga-2017-2018-1899-hoffenheim-borussia-dortmund/"; $html = new DOMDocument(); libxml_use_internal_errors(true); $html->loadHTMLFile($u
<?php
$url = "http://www.weltfussball.de/spielbericht/bundesliga-2017-2018-1899-hoffenheim-borussia-dortmund/";
$html = new DOMDocument();
libxml_use_internal_errors(true);
$html->loadHTMLFile($url);
$xpath = new DOMXPath($html);
libxml_clear_errors();
$xpath_team = $xpath->query('//table[3]/tr/th[1]');
print_r($xpath_team[0]);
?>
现在有趣的是:同一个脚本昨天没有出现任何问题。尽管如此,我还是找不到任何变化,无论是我的网站主持人,还是我试图从中获取内容的网站
我尝试对我的小代码示例进行一些更改,并检查了错误,但没有找到任何错误。因此,我尝试在谷歌上搜索出现的第一条错误行(因为这条对我来说是新的),但这并没有真正的帮助:
和往常一样,stackoverflow.com现在是我最后的希望,我想知道我所做的哪些错误导致了这场混乱。你用[3]点击的表格就是创建这场混乱的表格
。。。但这很有效,太累了,无法解释原因(可能明天):
//div[@class=“box”]/div[@class=“data”]//a
谢谢你的提示!我刚刚使用了表名作为目标。它也是独一无二的。然而,真正的问题本身就消失了。很奇怪。。。
<th align="center" width="35%"><a href="/teams/1899-hoffenheim/" title="1899 Hoffenheim">1899 Hoffenheim</a></th>
Warning: DOMDocument::loadHTMLFile() [domdocument.loadhtmlfile]: Sorry, an internal error occured. Please report this immediately! (2) in /users/spielerdaten/www/versuch1.php on line 7
Warning: DOMDocument::loadHTMLFile(http://www.weltfussball.de/spielbericht/bundesliga-2017-2018-1899-hoffenheim-borussia-dortmund/) [domdocument.loadhtmlfile]: failed to open stream: operation failed in /users/spielerdaten/www/versuch1.php on line 7