我正在尝试从这个网站获取数据:https://www.pontoslivelo.com.br/compreepontue/magazineluiza
我想要获取的数据是:enter image description here
这是我到目前为止拥有的代码:
$html = new simple_html_dom();
$html->load_file('https://www.pontoslivelo.com.br/compreepontue/magazineluiza');
foreach ($html->find('div[class=pontos-1]') as $div) {
echo $div->plaintext . "<br>";
}
不会返回任何内容。
$html->find('div[class=pontos-1]')
不是应该从代码中获取所有div吗?为什么他找不到class=pontos 1的那个?
发布于 2019-05-29 03:20:44
下载并将Simple HTML DOM首先包含在您的PHP文件中。
以下是您所需的代码
include_once('simple_html_dom.php');
$html = file_get_html('https://www.pontoslivelo.com.br/compreepontue/magazineluiza');
foreach($html->find('div[class=pontos-1]') as $element){
echo $element->innertext . '<br>';
}
https://stackoverflow.com/questions/56348330
复制相似问题