【发布时间】:2013-05-23 19:07:14
【问题描述】:
我正在抓取一些网站并保存数据,然后像这样回显数据:
echo $html->save();
$html 部分是保存完整网站的变量。我想在 iframe 中回显整个页面,通常我会放一个源 src="file.php?url=http://somewebsite.com" 如何回显变量而不是包括 iframe:
echo '<iframe src="$html->save()"></iframe>';
这在某种程度上是如何完成的,还是我完全是这样的?
我像这样使用 simple-html-dom 和 CURL:
require_once('simple_html_dom.php');
require_once('url_to_absolute.php');
$url = $_GET['url'];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$curl_scraped_page = curl_exec($ch);
$html = new simple_html_dom();
$html->load($curl_scraped_page, true, false);
foreach($html->find('a') as $a) {
$a->href = url_to_absolute($url, $a->href);
}
echo $html->save();
$html->clear();
【问题讨论】:
-
您愿意解释一下上下文吗?如果我帮助你做一些淘气的事情,我会很难过。
-
@George Cummins 刮痧没有什么不好的。我正在抓取一个新闻网站(合法),并希望在 iframe 中显示内容。但是,与其在 HTML 页面中使用常规 iframe,我更愿意回显 iframe(及其内容)。
-
$html->save()是否返回 HTML 数据?如果是这样,这可能会有所帮助:stackoverflow.com/q/6102636 -
为什么人们投反对票..??非常有用的问题..Google 上没有..