1

此脚本将从 url 动态获取网站地址。
示例:www.site.com/fetch.php?url=http://www.google.com使用 php 简单的 html dom 解析器获取其(google.com)内容,但我的脚本无法获取 url .. 任何想法>

$url = htmlentities($_GET['url']);
$html = file_get_html('$url')->plaintext;
$result = $html;
4

3 回答 3

0

不知道可以用这个$html=file_get_contents($_GET['url']);

于 2012-09-15T12:29:16.033 回答
0

不要引用$url变量:

$url = "htmlentities($_GET['url'])";
$html = file_get_html($url)->plaintext;
$result = $html;
于 2012-09-15T12:31:58.953 回答
0

您可以file_get_contents($_GET['url'])按照建议使用或 CURL

<?php
$ch = curl_init();
    $timeout = 5;
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch,CURLOPT_URL,$_GET['url']);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
    $data = curl_exec($ch);
    curl_close($ch);
    echo $data;
?>

要获得明文,您需要进行一些解析。你可以在这里得到

于 2012-09-15T12:32:16.280 回答