我从这个论坛找到了一个用于访问应用程序信息的脚本。基本上,我正在访问 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
发布评论
评论(1)
LWP::UserAgent 继承的
progress
子我认为你应该使用从文档中的
I think you should use the
progress
sub inherited from LWP::UserAgentfrom the docs: