Programmatically enter a forum and then creak

I would like to go to the community-server community forum (like http://forums.timesnapper.com/login.aspx?ReturnUrl=/forums/default.aspx ) and then load a specific page and execute a regex (see if there is messages awaiting moderation). If there is, I would like to send an email.

I would like to do this from a Linux server.

I currently know how to load the page (using for example wget) but there is a problem with the login. Any bright ideas how this works?

0


source to share


4 answers


Looking at the login page, this is an asp.net application, so you need to do a couple of things to achieve this -

Control the hidden __viewstate form field and submit it back when you submit your login details.



Once you're done, I am assuming that you can link to a specific page using only an absolute url, but you need to handle the ASP.NET Forms authentication cookie and submit that as part of the GET request.

+1


source


You may be in luck with Selenium or see this question for more suggestions:



Script for college class registration

+1


source


Personally, I would write it in Perl using WWW :: Mechanize and do something like:


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
}

      

I don't know if the above will work as I don't have the community server login details (whatever it is) to test it, but it should give you something that you could work with easily enough and shows power WWW :: Mechanize.

+1


source


You can do everything with wget. You need to submit the form using POST and store cookies. Relevant stuff on wget man page:

--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

      

0


source







All Articles