我想使用DOMXPath
来推断iframe
对象中消息的文本。
这是我到目前为止尝试过的:
$dom = new DOMDocument();
// We don't want to bother with white spaces
$dom->preserveWhiteSpace = false;
// Most HTML Developers are chimps and produce invalid markup...
$dom->strictErrorChecking = false;
$dom->recover = true;
$isSuccessful = @$dom->loadHTMLFile('https://t.me/Chelsea/874');
// Delay 1 second after the request to avoid getting BANNED
sleep(1);
// Check to see if URL is valid
if($isSuccessful === false)
{
//URL invalid!
echo "\"".$url."\" is invalid<br>";
return false;
}
$xpath = new DOMXPath($dom);
$hrefs=$xpath->query('//*[@id="widget"]/iframe');
但是,数组的长度为0
。
如何推断tgme_widget_message_text
类iframe
中的文本内容?