当我从curl得到回复时,我得到一个字符串格式的html,以下内容将起作用:
$html = str_get_html('<tr class="color_1">
<td class="texto" width="62px">
<div class="texto">
154848
</div>
</td>
<td class="texto" width="54px">
<div class="texto">
1547
</div>
</td>
</tr>');
foreach($html->find('tr td div.texto') as $element)
{
echo $element->innertext;
}
但是当我在str_get_html中更改文件时:
$html = str_get_html($table[0]);
foreach($html->find('tr td div.texto') as $element)
{
echo $element->innertext;
}
$ table [0]只是包含该表的html,我得到了下一个错误:致命错误:在
中的非对象上调用成员函数find()卷曲代码
curl_setopt($handler, CURLOPT_URL, $urlFechas);
curl_setopt($handler, CURLOPT_POST,true);
//Le vamos a enviar parámetros posts
curl_setopt($handler, CURLOPT_POSTFIELDS, $postdataFechas);
curl_setopt($handler, CURLOPT_COOKIEJAR, 'cookie.txt');
//Para poder guardar el html
curl_setopt($handler, CURLOPT_RETURNTRANSFER, true);
$url_destino2=curl_getinfo($handler, CURLINFO_EFFECTIVE_URL);
//Executamos
$response2 = curl_exec ($handler);
include_once('simple_html_dom.php');
//print "SISI";
$arrayHtml=explode('<table class="list">',$response2);
$tabla=explode('</table>',$arrayHtml[1]);