Linux 以编程方式登录论坛,然后进行ScreenSrap
我想登录到社区服务器的论坛部分(例如),然后下载一个特定页面并执行正则表达式(查看是否有帖子等待审核)。如果有,我想发一封电子邮件 我想在Linux服务器上执行此操作Linux 以编程方式登录论坛,然后进行ScreenSrap,linux,scripting,curl,wget,community-server,Linux,Scripting,Curl,Wget,Community Server,我想登录到社区服务器的论坛部分(例如),然后下载一个特定页面并执行正则表达式(查看是否有帖子等待审核)。如果有,我想发一封电子邮件 我想在Linux服务器上执行此操作 目前我知道如何下载页面(例如使用wget),但在登录时遇到问题。有什么好主意吗?您可能会更幸运地使用硒,或者查看此问题以获得更多建议: 您可能会更幸运地使用硒,或者查看此问题以获取更多建议: 查看登录页面的来源,它似乎是一个asp.net应用程序,因此您可能需要做一些事情来实现这一点- 管理表单隐藏的视图状态字段,并在提交登录详细
目前我知道如何下载页面(例如使用wget),但在登录时遇到问题。有什么好主意吗?您可能会更幸运地使用硒,或者查看此问题以获得更多建议:
您可能会更幸运地使用硒,或者查看此问题以获取更多建议:
查看登录页面的来源,它似乎是一个asp.net应用程序,因此您可能需要做一些事情来实现这一点- 管理表单隐藏的视图状态字段,并在提交登录详细信息时将其发回
一旦你通过了这个程序,我猜你可以使用一个绝对URL来引用所讨论的特定页面,但是你需要处理ASP.NET表单身份验证cookie,并将其作为get请求的一部分发送。查看登录页面的源代码,它似乎是一个ASP.NET应用程序,因此你可能需要做一些事情来验证它做到这一点- 管理表单隐藏的视图状态字段,并在提交登录详细信息时将其发回
我猜,一旦你通过了这个问题,你可以只使用绝对URL引用所讨论的特定页面,但你需要处理ASP.NET表单身份验证cookie,并将其作为get请求的一部分发送。我个人会用Perl编写它,使用,并执行以下操作:
my $login_url = 'login url here';
my $username = 'username';
my $password = 'password';
my $mech = new WWW::Mechanize;
$mech->get($login_url)
or die "Failed to fetch login page";
$mech->set_visible($username, $password)
or die "Failed to find fields to complete";
$mech->submit
or die "Failed to submit form";
if ($mech->content() =~ /posts awaiting moderation/i) {
# Do something here
}
我不知道上面的方法是否有效,因为我没有社区服务器(无论是什么)的登录详细信息来测试它,但它应该能让你很容易地使用它,并显示出WWW::Mechanize的强大功能。我个人会用Perl编写它,使用,并执行以下操作:
my $login_url = 'login url here';
my $username = 'username';
my $password = 'password';
my $mech = new WWW::Mechanize;
$mech->get($login_url)
or die "Failed to fetch login page";
$mech->set_visible($username, $password)
or die "Failed to find fields to complete";
$mech->submit
or die "Failed to submit form";
if ($mech->content() =~ /posts awaiting moderation/i) {
# Do something here
}
我不知道上面的方法是否有效,因为我没有社区服务器(无论是什么)的登录详细信息来测试它,但它应该能让你很容易地使用它,并显示出WWW::Mechanize的强大功能。你可以用wget完成所有工作。您需要使用POST提交表单,并且需要存储cookie。wget手册页中的相关内容:
--post-data=string
--post-file=file
Use POST as the method for all HTTP requests and send the specified data in the request body.
"--post-data" sends string as data, whereas "--post-file" sends the contents of file. Other than
that, they work in exactly the same way.
This example shows how to log to a server using POST and then proceed to download the desired pages,
presumably only accessible to authorized users:
# Log in to the server. This can be done only once.
wget --save-cookies cookies.txt \
--post-data 'user=foo&password=bar' \
http://server.com/auth.php
# Now grab the page or pages we care about.
wget --load-cookies cookies.txt \
-p http://server.com/interesting/article.php
你可以用wget来完成这一切。您需要使用POST提交表单,并且需要存储cookie。wget手册页中的相关内容:
--post-data=string
--post-file=file
Use POST as the method for all HTTP requests and send the specified data in the request body.
"--post-data" sends string as data, whereas "--post-file" sends the contents of file. Other than
that, they work in exactly the same way.
This example shows how to log to a server using POST and then proceed to download the desired pages,
presumably only accessible to authorized users:
# Log in to the server. This can be done only once.
wget --save-cookies cookies.txt \
--post-data 'user=foo&password=bar' \
http://server.com/auth.php
# Now grab the page or pages we care about.
wget --load-cookies cookies.txt \
-p http://server.com/interesting/article.php
你比我快了10秒:)你比我快了10秒:)是的,这更像我想的。。。但这似乎是一个大麻烦!是的,这更像是我想的。。。但这似乎是一个大麻烦!