passing external data to web forms

M L mlsngac at gmail.com
Mon May 31 13:16:22 EDT 2010


(Note: If you just skim this and can tell me how to pass data from an
external program to a web form, that's all I need, and the rest is
just what I'd like to have.)

This is probably extremely simple when you know what you're doing. I
figured I'd see if I could find a kind soul who
could give me some code samples. Here's what I need to do:

1. Receive email via IMAP-IDLE
2. Parse the email to see if it contains certain text
3. Open a browser window with the following variables based on what
that text is
  a. URL
  b. username
  c. password

Specifically, I'm needing to login to a particular website, and which
username I use varies based on it being specified in the email. I
tried to do this with a combination of message filters in Thunderbird
and command line arguments in Firefox, but it can't quite do
everything I need.

My real problem is how to get the username and password passed to the
browser. Also, you should know that the server to which I'm connecting
is a site to which I subscribe, not my own, so I can't run anything
sever-side. Also, if possible, having this just fill whatever the
first html form field it comes to with the username and the second
with the password would be great, though not necessary if that's
significantly more complicated than it filling them based on a
specific name. I don't anticipate the site changing the names of those
fields, but I'd like to not have to redo the code if it does.

Finally, and again just a preference not a requirement, I feel that it
would be easier to have an external file that stores the usernames and
passwords that could be referenced to load them based on the email
contents rather than having the usernames and passwords hardcoded.
However, I'm only needing about half a dozen, so if it's significantly
simpler, I'll go with that.

Thanks for any help!

-ML



More information about the Python-list mailing list