[英]PHP DOM function file_get_html call after Complete Page load
We are trying to fetch url from PHP DOM
but webapge that we try to fetch has functionality (change price after page load) so now we need that PHP Dom
function file_get_html
get HTML after this onload
functionality of remote page has been completed. 我们正在尝试从PHP DOM
获取URL但是我们尝试获取的webapge具有功能(在页面加载后更改价格)所以现在我们需要PHP Dom
函数file_get_html
在远程页面的这个onload
功能完成后获取HTML。
$html = file_get_html('https://www.example.com');
// Find all article blocks
foreach($html->find('div.pad15 h4 a') as $article) {
echo $article->innertext.'<br>';
}
foreach($html->find('p.sprc span.fb') as $pr){
echo $pr->innertext.'<br>';
}
$html->clear();
unset($html);
if I right undestend question you problem is get html after loading js. 如果我对不受欢迎的问题你的问题是在加载js后得到html。 It's impossible. 不可能。 Becouse php open connection and get data at once Becouse php open connection并立即获取数据
answer about you question is "NO" 回答你的问题是“不”
php can not receive javascript rendered result. php无法接收javascript渲染结果。 javascript is running on browser side and it not possible with php. javascript在浏览器端运行,用php无法实现。
alternative is to do task with 替代方案是做任务
http://phantomjs.org/ http://phantomjs.org/
var page = require('webpage').create();
page.open('http://google.com', function () {
console.log(page.content);
phantom.exit();
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.