【发布时间】:2013-02-10 06:01:49
【问题描述】:
我想知道是否有可能使此代码搜索该网站的每个页面,以便从所有页面中提取每个图像 src。目前它只会从那一页中提取图像 src。我尝试使用 while 循环,但它只会一遍又一遍地重复主页上的相同结果。任何帮助都会很棒。
<?php
include_once('simple_html_dom.php');
//show errors
ini_set('display_errors', true);
error_reporting(E_ALL);
$html = file_get_html('http://betatv.net/');
$result=($html);
while($html = ($result)) {
// find the show img and echo it out
foreach($html->find('.entry-content') as $cover_img)
foreach($cover_img->find('img') as $cover_img_link)
//echo the images src
echo $cover_img_link->src .'<br>';
echo '<br>';
}
// clean up memory
$html->clear();
unset($html);
?>
证明我拥有 betatv.net 我在首页添加了指向此问题的链接。
【问题讨论】:
-
betatv.net 中奖了吗?如果没有,您可能不应该这样做;而且您需要一个非常复杂的脚本才能在您不拥有的服务器上执行此操作。如果你这样做,请更新你的问题,这样说(如果你“拥有”服务器,执行你所要求的脚本将非常相似)。
-
是的,我拥有 betatv.net。
-
我在首页添加了这个问题的链接作为证据。
-
有人吗?真的可以在这方面使用一些帮助。
-
我目前正在解决另一个用户的问题,但是为了让您朝着正确的方向开始,请查看 PHP 的 glob 函数 (php.net/manual/en/function.glob .php)。您将需要打开每个文本文件并将其传递到上面的脚本中。另外,考虑到现在是北美和欧洲的凌晨。