有没有开源的 PHP Web 代理可供使用?

发布于 2024-10-09 17:58:32 字数 571 浏览 0 评论 0原文

我需要一个 PHP Web 代理来读取 html、向用户显示并重写所有链接,以便当用户单击下一个链接时,代理将再次处理请求,就像此代码一样,但另外还需要重写所有链接链接。

<?php
// Set your return content type
header('Content-type: text/html');

// Website url to open
$daurl = 'http://www.yahoo.com';

// Get that website's content
$handle = fopen($daurl, "r");

// If there is something, read and return
if ($handle) {
    while (!feof($handle)) {
        $buffer = fgets($handle, 4096);
        echo $buffer;
    }
    fclose($handle);
}
?>

我希望我已经解释得很好了。这个问题是为了不要重新发明轮子。

另一个附加问题。这种代理可以处理Flash之类的内容吗?

I need a PHP Web Proxy that read html, show to the user and rewrite all the links for when the user click in the next link the proxy will handle the request again, just like this code, but with additionaly sould make the rewrite of all the links.

<?php
// Set your return content type
header('Content-type: text/html');

// Website url to open
$daurl = 'http://www.yahoo.com';

// Get that website's content
$handle = fopen($daurl, "r");

// If there is something, read and return
if ($handle) {
    while (!feof($handle)) {
        $buffer = fgets($handle, 4096);
        echo $buffer;
    }
    fclose($handle);
}
?>

I hope I have explained well. This question is for not reinventing the wheel.

Another additional question. This kind of proxies will deal with contents like Flash?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

分开我的手 2024-10-16 17:58:32

对于开源解决方案,请查看 PHProxy。我过去用过它,据我记忆,它似乎工作得很好。

For an open source solution, check out PHProxy. I've used it in the past and it seemed to work quite well from what I can remember.

千纸鹤 2024-10-16 17:58:32

它会起作用,你需要重写任何相对路径到绝对路径,我认为cookie在这种情况下不起作用。使用 cURL 进行此操作...

function curl($url){
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,$url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
    return curl_exec($ch);
    curl_close ($ch);
}

$url = "http://www.yahoo.com";

echo curl($url);

It will sort of work, you need to rewrite any relative path to apsolute, and I think cookies won't work in this case. Use cURL for this operations...

function curl($url){
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,$url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
    return curl_exec($ch);
    curl_close ($ch);
}

$url = "http://www.yahoo.com";

echo curl($url);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文