[Wylug-help] Automate web logins

Smylers Smylers at stripey.com
Sat Jun 26 09:03:57 BST 2004


Idris Fulat writes:

> Hi, I have a little VB app that fills out a web page with login
> details then logs in. This process is repeated via the task schedular
> every ten mins so you are never logged out of the net as it times out
> every ten mins. I would like to replicate this MS process on some
> machines running Debian. I have, however not the first clue as to how
> to go about doing it except i'm sure a simple script would suffice.

Nobody else seems to've responded to this from Wednesday, so I'll offer
what I have.

Firstly the 'every 10 minutes' bit is easy: cron can run any command at
pretty much any time interval you want just by dropping a file into
/etc/cron.d/.

One way of programmatically pretending to be a human browsing a website
is to write a Perl script using the WWW::Mechanize module, which does
the awkward bits: you just have to provide the specifics for your
particular site.  The HTTP::Recorder module can even be set up as a
local web-proxy to write a WWW::Mechanize script for you as you just
browse the site in question!  However, if you haven't encountered any
Perl before then doing even this is far from trivial.

wget is a command-line program for grabbing a webpage and saving it to a
file.  Depending on the complexity of the site, it may be that making a
single HTTP get request is sufficient to log you in, perhaps something
like:

  http://www.example.com/login.cgi?user=Aardvark&password=blue

The sites' HTML log-in form almost certainly uses post rather than get
to send the data, but the script processing the submission may well
accept either; you can work out what the get equivalent is either by
reading the HTML source of the form, or using 'Mozilla Firefox' with the
Live HTTP Headers plug-in.

> Any detailed help appreciated.

I wouldn't describe what I've written above as "detailed", but this help
list is a free service, so the quality of answers is dependent on what
respondents feel like offering rather than what those seeking help ask
for!

More to the point, I don't know what you already know -- you may well be
_a fait_ with cron or Live HTTP Headers or whatever, and it'd be a
complete waste of my time to think up and type out detailed instructions
on exactly how to use them.  But please don't let that put you off
asking follow-up questions: if you have specific questions about any of
the above then I, and I'm sure others on the list, will try to help.

Smylers





More information about the Wylug-help mailing list