将simplehtmldom与ajax结合使用


using simple_html_dom with ajax

我正在用"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)。

尝试使用此

<?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>';
}
?>

===更新===

实际上,这是一个iframe,它不是ajax。在的中心http://www.playnow3dgames.com/genre.php?id=sports是框架:http://www.playnow3dgames.com/listing.php?genre=sports&订单=日期

你可以看到url的结构:

http://www.playnow3dgames.com/listing.php?genre=sports&order=date

在这里:genre=sports

这是真实的网址:http://www.playnow3dgames.com/genre.php?id=sports

您将看到id=sportsgenre=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=strategy

url将为:

http://www.playnow3dgames.com/listing.php?genre=strategy&page=2&order=date