web scrapping - POST and auto-login
james <at> hal-pc.org
james <at> hal-pc.org
Mon Sep 19 19:49:12 EDT 2005
please excuse my ignorance of Python. i know enough to be dangerous
(was able however to make Freevo support my FM tuner with a little hacking).
Ultimate goal:
read N bytes from PATTERN on page A into VARIABLE.
POST VARIABLE into TABLE on site B.
email VARIABLE to myself.
what i have to work with:
---------------------------
#!/usr/local/bin/python
from urllib import urlopen
from re import search
URL = "http://wifirouter/WL_WPATable.asp"
pattern = "wl_key1 value='*([0-9,a-f,]*)"
doc = urlopen(URL).read()
result = search(pattern, doc)
print result.group(1)
---------------------------
I'm trying to update the WEP key on a wireless router via script and
email the results to myself. this will be run once a week. Site A
already generates random keys, so i figure that's a good place to get
VARIABLE from. The example above gives me the current key of the router.
What i'm having trouble with is the key on site A (one i wrote myself
http://www.hal-pc.org/networking/cgi-bin/wepgen.cgi ) provides 128bit
keys by default, but i only want to use 64bit (10 characters). so..
rather than make it select 64bit and all i figure it would be easier to
use the above example for getting the /current/ key, modified it to read
the entire 26 character string from site A, but [1] how do i crop it to
10 characters.
[2] how can i then auto-login to site B (the router's web config via
pop-up dialog box. *not* a form) and then [3] post VARIABLE and save the
changes.
I know this sounds like a lot, but if anyone can provide me with any
example code i can maybe modify to fit, or point me to some good
reference material. all the pages i found on logging into a site
involve ssl and cookies, which, in this case at least, isn't involved here.
If there is any other info i can provide (ie. sections of relevent
HTML) then let me know. any assistance you have to offer is greatly
appreciated.
--
- - james <at> hal-pc.org - -
"Friends don't let friends use Mandrake"
- - - - - - - - - - - - - - -
More information about the Python-list
mailing list