机械化和 Facebook 应用程序

发布于 2024-10-31 11:23:40 字数 925 浏览 4 评论 0原文

我从这个论坛找到了一个用于访问应用程序信息的脚本。基本上,我正在访问 Facebook 应用程序,并且可能会自动安装它。

我尝试查看是否通过以下代码获得权限对话框页面,但它不会返回权限页面而不是第一页。

facebook 所做的是多次重定向或元或发送一些其他请求,然后将用户带到我需要单击允许按钮的权限页面。但我无法获得许多应用程序的最终权限页面。这是代码,

use strict;
use WWW::Mechanize;
use HTTP::Cookies;

my $url = "http://www.facebook.com";

my $appurl = "http://apps.facebook.com/funmoods/";

my $username = 'mail';
my $password = 'pass';

my $mech = WWW::Mechanize->new();
$mech->cookie_jar(HTTP::Cookies->new());
$mech->get($url);
$mech->form_name('menubar_login');
$mech->field(email => $username);
$mech->field(pass => $password);
$mech->click();
my $facebook_content = $mech->content();
# go to an app url
$mech->get($appurl);
my $app_content = $mech->content();
print "$app_content\n";

我不知道为什么 mechanize 无法访问最终加载的页面。加载权限页面需要一些时间,但 mechanize 总是返回第一个源页面。我如何告诉 mechanize 等待它加载所有页面?

需要帮助谢谢

I found one script for accessing app info from this forum.Basically, i am accessing facebook apps and may install it automatically.

I tried to see if i get a permission dialog page by following code but it does not return the permission page rather the first page.

what facebook do is multiple redirects or meta or sends few other request and then lands the user to permission page where i need to click allow button. But i am not able to get that final permission page for many apps. Here is the code,

use strict;
use WWW::Mechanize;
use HTTP::Cookies;

my $url = "http://www.facebook.com";

my $appurl = "http://apps.facebook.com/funmoods/";

my $username = 'mail';
my $password = 'pass';

my $mech = WWW::Mechanize->new();
$mech->cookie_jar(HTTP::Cookies->new());
$mech->get($url);
$mech->form_name('menubar_login');
$mech->field(email => $username);
$mech->field(pass => $password);
$mech->click();
my $facebook_content = $mech->content();
# go to an app url
$mech->get($appurl);
my $app_content = $mech->content();
print "$app_content\n";

I don't know why mechanize does not access final loaded page. it took some time to load the permission page but mechanize always returns first source page. How i can tell mechanize to wait till it loads all the pages?

Need help thanks

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

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

发布评论

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

评论(1

帅气称霸 2024-11-07 11:23:40

LWP::UserAgent 继承的 progress

$ua->progress( $status, $request_or_response ) 

我认为你应该使用从文档中的

这经常被称为
无论如何都会收到响应
内容已处理。方法
被调用时 $status "begin" 在
开始处理请求并且
在请求之前加上 $state "end"
方法返回。在这些之间
$status 将是
当前收到的响应或
如果分数不能是字符串“tick”
已计算。

当 $status 为“开始”时,第二个
参数是请求对象,
否则它是响应对象。

I think you should use the progress sub inherited from LWP::UserAgent

$ua->progress( $status, $request_or_response ) 

from the docs:

This is called frequently as the
response is received regardless of how
the content is processed. The method
is called with $status "begin" at the
start of processing the request and
with $state "end" before the request
method returns. In between these
$status will be the fraction of the
response currently received or the
string "tick" if the fraction can't be
calculated.

When $status is "begin" the second
argument is the request object,
otherwise it is the response object.

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