使用 LWP::UserAgent 的 Perl 代码在做什么?
我有这段代码:
use strict;
use LWP::UserAgent;
use warnings;
my $ua = new LWP::UserAgent(agent => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.5) Gecko/20060719 Firefox/1.5.0.5');
$ua->proxy([qw(http https)] => 'http://59.39.92.148:1080');
my $response = $ua->get("http://www.google.com");
print $response->code,' ', $response->message,"\n";
代码的含义是“使用sock代理打开www.google.com”吗?解释是什么?
I have this code:
use strict;
use LWP::UserAgent;
use warnings;
my $ua = new LWP::UserAgent(agent => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.5) Gecko/20060719 Firefox/1.5.0.5');
$ua->proxy([qw(http https)] => 'http://59.39.92.148:1080');
my $response = $ua->get("http://www.google.com");
print $response->code,' ', $response->message,"\n";
Is the meaning of the code "open www.google.com with sock proxy"? What is the explanation?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
它正在实例化一个 LWP::UserAgent 对象。
参数指定浏览器Mozilla Firefox
连接代理的地址和端口 'http://59.39.92.148:1080'
响应是 Google 通过代理传递的:
我的 $response = $ua->get("http://www.google.com ");`
最后:
允许向用户做出响应
我是一名 C# 开发人员,但这就是我的看法:)
It's instantiating an LWP::UserAgent object.
The parameters specify the browser Mozilla Firefox
The address and port to connect to the proxy 'http://59.39.92.148:1080'
and the response is Google passed through the proxy:
my $response = $ua->get("http://www.google.com");`
Finally:
allows a response to be posed back to the user
I'm a C# developer, but that's how it looks to me :)
该代码正在设置一个 LWP::UserAgent 对象来伪装成使用的浏览器由人类绕过谷歌的蜘蛛检测机制。这样做违反了 Google 服务条款:
59.39.92.148
可能是中国一些受损(或配置错误)的开放代理。设置$ua
来使用它是试图隐藏 TOS 违规的根源。顺便说一句,您应该知道,如果您决定走这条路线,
59.39.92.148
的服务器将能够记录和跟踪您的所有请求和响应。更重要的问题是:你想做什么?
The code is setting up an LWP::UserAgent object to masquerade as a browser used by a human being to bypass Google's spider detection mechanism. In doing so, it violates Google's Terms of Service:
59.39.92.148
is probably some compromised (or badly configured) open proxy in China. Setting$ua
to use it is an attempt to hide the origin of the TOS violation.Incidentally, you should be aware that the server at
59.39.92.148
will be able to log and track all your requests and responses should you decide to go down this route.The more important question is: What are you trying to do?
看起来像:使用 HTTP 代理打开“www.google.com”
Looks like: Open "www.google.com" using an HTTP Proxy