我正试图从下面的页面中找到特定的元素:
$links=array(
"https://www.computers.com/l_bg/?m=7&i=587609",
"https://www.computers.com/l_bg/?m=7&i=587610",
"https://www.computers.com/l_bg/?m=7&i=587607",
"https://www.computers.com/l_bg/?m=7&i=587502"
);
foreach($links as $link){
$newhtml = new simple_html_dom();
$newhtml->load_file($link);
foreach($newhtml->find('table.fpt > td.name') as $price){
echo $price=$price->innertext;
}
}
但是$price是空的。。奇怪的是,如果我把代码改成这样:
$newhtml = new simple_html_dom();
$newhtml->load_file('https://www.computers.com/l_bg/?m=7&i=587609');
foreach($newhtml->find('table.fpt > td.name') as $price){
echo $price=$price->innertext;
}
代码有效。。为什么如果我手动放置url,它可以工作,但当在循环中时,它不可以?你能告诉我出了什么问题以及如何找到它吗?
问题似乎是编码问题。如果url具有&它被转换为CCD_ 1,必须用&为了工作。。无论如何,谢谢你的帮助!