从他们的文档它看起来像找到返回数组匹配过滤器参数的匹配值:
来自:
http://simplehtmldom.sourceforge.net/
代码:
// Find all images
foreach($html->find('img') as $element)
echo $element->src . '<br>';
他们还为获得一个特定的元素提供了另一个例子:
$html->find('div[id=hello]', 0)->innertext = 'foo';
所以我的猜测是这样的事情会得到你想要你的愿望:
$value = $html->find('span.contact-seller-name', 0);
echo $value->innertext;
通过广告将其作为参数返回该过滤器的第一个找到的实例。
在它们的API看一看这里:
http://simplehtmldom.sourceforge.net/manual_api.htm
它描述什么找到方法返回(元素对象或元对象组成的数组,如果第二参数定义)
然后,使用为元素对象提供的任何方法都可以获得所需的文本。
$url = "http://fleeceandthankyou.org/";
$html = file_get_html($url);
$value = $html->find('span.givecamp-header-wide', 0);
//If it can't find the element, throw an error
try
{
echo $value->innertext;
}
catch (Exception $e)
{
echo "Couldn't access magic method: " . $e->getMessage();
}
可以请你详细说明你的意思是通过回声成什么:
全部工作例如在直播现场测试? –
您的代码中没有定义变量'$ post' – empiric
现在我已更正了我的代码。我想在范围标记中回显'Enda' – Ahmed