python and web pages

D

Daniel Dalton

Hi,

Here is my situation:
I'm using the command line, as in, I'm not starting gnome or kde (I'm on
linux.)
I have a string of text attached to a variable,. So I need to use one of
the browsers on linux, that run under the command line, eg. lynx,
elinks, links, links2 and do the following.
1. Open a certain web page and find the first text box on the page, and
put this text into the form.
2. Press the submit button, and wait for the result page to load.
3. Click on the 15th link down the page.

So, how do I do this, can anyone point me to some docs or modules that
may help out here?

Thank you,
 
D

Diez B. Roggisch

Daniel said:
Hi,

Here is my situation:
I'm using the command line, as in, I'm not starting gnome or kde (I'm on
linux.)
I have a string of text attached to a variable,. So I need to use one of
the browsers on linux, that run under the command line, eg. lynx,
elinks, links, links2 and do the following.
1. Open a certain web page and find the first text box on the page, and
put this text into the form.
2. Press the submit button, and wait for the result page to load.
3. Click on the 15th link down the page.

So, how do I do this, can anyone point me to some docs or modules that
may help out here?

Use the module "mechanize". It will mimic a browser, and allows you to
navigate to pages, fill in forms & submit them.

And with lxml or BeatifulSoup, you can extract the link you need to
press, and then make mechanize visit it.

Diez
 
D

Daniel Dalton

Use the module "mechanize". It will mimic a browser, and allows you
to navigate to pages, fill in forms & submit them.

Well, what seemed a very daunting task at first, proved to be quite
easy, after a little bit of research. Thanks very much, I've written my
script, and it works correctly, using the mechanize module.

Thanks for everyone's help

--
Cheers,
Dan

http://members.iinet.net.au/~ddalton/


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAksHRpUACgkQQCYsNYjKJVCUjACggRKd2RtYwo0KpY06WmSpA8Uv
2b0AoMNIN3e6lh1+7aBQsw92TR2Xs9lX
=QAMe
-----END PGP SIGNATURE-----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,184
Messages
2,570,973
Members
47,530
Latest member
jameswilliam1

Latest Threads

Top