我正在使用'simple_html_dom‘库解析页面,但是解析其内容是通过ajax获得的html没有成功。有办法绕过这件事吗?
PHP代码:
<?php
require_once '../library/Simple_HTML_DOM/simple_html_dom.php';
// Create DOM from URL or file
$html = file_get_html('http://www.playnow3dgames.com/genre.php?id=sports');
// Find all images
foreach($html->find('img') as $element){
echo $element->src . '<br>';
}
?>只在边缘和顶部打印图像(html本机),不解析中心图像(使用ajax)。
发布于 2015-02-11 13:38:39
试试这个
<?php
require_once '../library/Simple_HTML_DOM/simple_html_dom.php';
// Create DOM from URL or file
$html = file_get_html('http://www.playnow3dgames.com/listing.php?genre=sports&order=date');
// Find all images
foreach($html->find('img') as $element){
echo $element->src . '<br>';
}
?>===更新====
实际上,这不是ajax。http://www.playnow3dgames.com/genre.php?id=sports的中心是框架:http://www.playnow3dgames.com/listing.php?genre=sports&order=date
您可以看到url的结构:
http://www.playnow3dgames.com/listing.php?genre=sports&order=date在这里:genre=sports
这是真实的url:http://www.playnow3dgames.com/genre.php?id=sports
您将看到id=sports与genre=sports的匹配。
要获取每个页面,只需更改genre=genre_name即可。例如:
http://www.playnow3dgames.com/genre.php?id=strategy主要框架如下:
www.playnow3dgames.com/listing.php?genre=strategy&order=date如果你想得到第1,2,3页.,你需要添加page=page_number。例如:获取第2页
http://www.playnow3dgames.com/genre.php?id=strategyurl为:
http://www.playnow3dgames.com/listing.php?genre=strategy&page=2&order=datehttps://stackoverflow.com/questions/28455695
复制相似问题