0

community-server の Forums 部分 (例: http://forums.timesnapper.com/login.aspx?ReturnUrl=/forums/default.aspx ) にログインし、特定のページをダウンロードして正規表現 (モデレート待ちの投稿があるかどうかを確認します)。もしあれば、メールを送りたいです。

これを Linux サーバーから実行したいと考えています。

現在、ページをダウンロードする方法 (wget などを使用) は知っていますが、ログインに問題があります。

4

4 に答える 4

1

Selenium の方がうまくいくか、この質問を参照してその他の提案を確認してください。

大学の授業登録のスクリプト

于 2008-11-19T17:01:17.107 に答える
1

ログインページのソースを見ると、それはasp.netアプリのように見えるので、これを達成するにはおそらくいくつかのことをする必要があります-

フォームの非表示の __viewstate フィールドを管理し、ログインの詳細を送信するときにそれを投稿します。

それを乗り越えたら、絶対 URL を使用するだけで問題の特定のページを参照できると思いますが、ASP.NET フォーム認証 Cookie を処理し、GET 要求の一部として送信する必要があります。

于 2008-11-19T17:01:34.157 に答える
1

個人的には、 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。

于 2008-12-28T19:38:32.933 に答える
0

すべて wget で実行できます。POST を使用してフォームを送信し、Cookie を保存する必要があります。wget の man ページの関連するもの:

--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
于 2009-08-11T06:22:47.947 に答える