我想要做的是获取此页面 http://www.tibia.com/community/?subtopic=characters&name=Helix+Pelegando 从这个页面得到所有的死亡,我陷入困境 谁知道我做错了什么?
编辑 - 问题是我根本没有得到任何结果
$html = file_get_contents('http://www.tibia.com/community/?subtopic=characters&name=Helix+Pelegando');
$domd = new domDocument;
$domx = new DOMXPath($domd);
$domd->loadHTML($html);
$worlds = $domx->query("//*b[text() = 'Character Deaths']/ancestor::table[1]//tr[position() > 1]");
$deaths = array();
foreach ($worlds as $row) {
$date = $row->firstChild->nodeValue;
$text = $row->lastChild->nodeValue;
preg_match("/Died at Level (\\d+) by (.+)\\./", $text, $matches);
$deaths[] = array(
"date" => DateTime::createFromFormat("M d Y, H:i:s T", $date),
"level" => $matches[1],
"reason" => $matches[2],
);
}