如何使用 cURL 和PHP 欺骗引荐来源网址?

发布于 2024-10-07 13:50:31 字数 611 浏览 0 评论 0原文

我正在尝试使用 PHP 学习 cURL 来欺骗网站的引荐来源网址。

我希望通过以下脚本来完成此任务...但它似乎不起作用。

有什么想法/建议我哪里出错了?

或者你知道有什么教程可以帮助我解决这个问题吗?

谢谢!

杰西卡

<?php
$host = "http://mysite.com";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $host);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_AUTOREFERER, false);
curl_setopt($ch, CURLOPT_REFERER, "http://google.com");
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_HEADER, 0);
$result = curl_exec($ch);
curl_close($ch);
?>

I'm trying to learn cURL with PHP to spoof the referrer to a website.

With the following script I expected to accomplish this...but it seems to not work.

Any ideas/suggestion where I am going wrong??

Or do you know of any tutorials that could help me figure this out?

Thanks!

Jessica

<?php
$host = "http://mysite.com";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $host);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_AUTOREFERER, false);
curl_setopt($ch, CURLOPT_REFERER, "http://google.com");
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_HEADER, 0);
$result = curl_exec($ch);
curl_close($ch);
?>

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

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

发布评论

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

评论(1

叹沉浮 2024-10-14 13:50:31

您将无法在网络服务器的分析中看到结果,因为它可能使用 javascript 来获取分析,而curl 不会运行/执行 javascript。 Curl 所做的就是获取页面的内容,就像它是一个文本文件一样。它不会运行任何脚本或任何东西。

更清楚地说,如果您有像

<img src="path/to/image/image.jpg" />

The curl 这样的 html 标签,则会将其视为一行文本。它不会从服务器加载 image.jpg。如果js是a,情况也是如此。

<script type="text/javascript" src="analytics.js"></script>

通常浏览器会加载analytics.js并运行它,但curl不会。

You wont be able to see the result in webserver's analytics because it might probably using a javascript to get the analytics and curl wont run/execute the javascript. All Curl will do is get the content of the page as it like it is a text file. It wont run any of the scripts or anything.

To be more clear if you have an html tag like

<img src="path/to/image/image.jpg" />

The curl will treat it as a line of text. it wont load the image.jpg from the server. The same goes with the js if their is a

<script type="text/javascript" src="analytics.js"></script>

Normally the browser will load that analytics.js and run it, but the curl wont.

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