Javascript 使用简单的HTMLDOM解析rss提要不适用于任何元素
我使用简单的HTML DOM来筛选rss提要,这是我的代码: 需要一次域目录simple_html_dom.php'Javascript 使用简单的HTMLDOM解析rss提要不适用于任何元素,javascript,php,dom,rss,Javascript,Php,Dom,Rss,我使用简单的HTML DOM来筛选rss提要,这是我的代码: 需要一次域目录simple_html_dom.php' $articles = array(); getArticles('http://rss.sciencedirect.com/publication/science/09218009'); function getArticles($page) { global $articles; $html = new simple_html_dom(); $ht
$articles = array();
getArticles('http://rss.sciencedirect.com/publication/science/09218009');
function getArticles($page) {
global $articles;
$html = new simple_html_dom();
$html->load_file($page);
//echo $html;
$items = $html->find('.entry');
echo sizeof($items);
/*foreach($items as $post) {
# remember comments count as nodes
$articles[] = $post->innertext;
//echo $html;
}
foreach($articles as $item) {
echo "<div class='item'>";
echo $item;
echo "</div>";
}*/
}
$articles=array();
getArticles('http://rss.sciencedirect.com/publication/science/09218009');
函数getArticles($page){
全球$物品;
$html=新的简单html\U dom();
$html->load_文件($page);
//echo$html;
$items=$html->find('.entry');
echo sizeof(项目);
/*foreach(项目作为$post){
#记住,注释作为节点计算
$articles[]=$post->innertext;
//echo$html;
}
foreach($articles作为$item){
回声“;
echo$项目;
回声“;
}*/
}
好的方面是load\u file($page)
工作正常,当我将其输出到浏览器时,它会显示整个页面
到目前为止一切顺利
现在的问题是,$items
等于[],是的,nada
当我分析dom时,我发现有一个javascript初始化函数,我怀疑它是罪魁祸首
我需要知道如何:
谢谢您能澄清一下“某种js初始化”是什么意思吗?您链接的页面没有任何html或js,只是xml。也没有任何样式元素,因此“.entry”不存在。您的意思是要搜索“item”标记吗?javascript部分位于标题中,类似于
ScienceDirect Publication:economic Economics-chrome-urlchrome://browser/content/feeds/subscribe.js
WriteContent()是初始化代码?它在加载时发生。我需要在不使用浏览器的情况下加载页面,JS是您的浏览器添加的内容,以便您可以从浏览器中订阅它。PHP显然不会看到它,因为它没有使用浏览器。它只看到纯XML提要,这是服务器实际发送的全部内容。如果您使用“查看源代码”而不是使用例如Firebug,您将明白我的意思。@rjdown,谢谢。我明白你的意思以及如何解决这个问题。进行!