How to execute a hyperlink?

M

Muddy Coder

Hi Folks,

Module os provides a means of running shell commands, such as:

import os
os.system('dir .')

will execute command dir

I think a hyperlink should also be executed. I tried:

os.system('http://somedomain.com/foo.cgi?name=foo&passwd=bar')

but I got kicked out by the Python interpreter. I wonder somebody
knows the syntax of triggering a hyperlink? Thanks in advance!


Muddy Coder
 
J

Jon Clements

Hi Folks,

Module os provides a means of running shell commands, such as:

import os
os.system('dir .')

will execute command dir

I think a hyperlink should also be executed. I tried:

os.system('http://somedomain.com/foo.cgi?name=foo&passwd=bar')

but I got kicked out by the Python interpreter. I wonder somebody
knows the syntax of triggering a hyperlink? Thanks in advance!

Muddy Coder

The webbrowser module springs to mind.

hth
Jon.
 
R

Roel Schroeven

Muddy Coder schreef:
Hi Folks,

Module os provides a means of running shell commands, such as:

import os
os.system('dir .')

will execute command dir

I think a hyperlink should also be executed. I tried:

os.system('http://somedomain.com/foo.cgi?name=foo&passwd=bar')

but I got kicked out by the Python interpreter. I wonder somebody
knows the syntax of triggering a hyperlink? Thanks in advance!

As others have said, you can use the webbrowser module for hyperlinks.
Alternatively you can use os.startfile() which works hyperlinks and many
types of files, but only works on Windows (it does the same as
double-clicking in Windows Explorer).

--
The saddest aspect of life right now is that science gathers knowledge
faster than society gathers wisdom.
-- Isaac Asimov

Roel Schroeven
 
B

Barak, Ron

Hi Muddy,

http://docs.python.org/library/urllib2.html may help.

Bye,
Ron.

-----Original Message-----
From: Muddy Coder [mailto:[email protected]]
Sent: Wednesday, January 28, 2009 03:00
To: (e-mail address removed)
Subject: How to execute a hyperlink?

Hi Folks,

Module os provides a means of running shell commands, such as:

import os
os.system('dir .')

will execute command dir

I think a hyperlink should also be executed. I tried:

os.system('http://somedomain.com/foo.cgi?name=foo&passwd=bar')

but I got kicked out by the Python interpreter. I wonder somebody knows the syntax of triggering a hyperlink? Thanks in advance!


Muddy Coder
 
C

Cameron Laird

Muddy Coder schreef:

As others have said, you can use the webbrowser module for hyperlinks.
Alternatively you can use os.startfile() which works hyperlinks and many
types of files, but only works on Windows (it does the same as
double-clicking in Windows Explorer).
.
.
.
I suspect that os.startfile() will indeed give Muddy Coder
the most immediate satisfaction. It might interest him,
though, also to experiment with

os.system("start %s" % URL)

Again, recognize this only gives happy results, in general,
under Win*.
 
J

Jeff McNeil

Hi Folks,

Module os provides a means of running shell commands, such as:

import os
os.system('dir .')

will execute command dir

I think a hyperlink should also be executed. I tried:

os.system('http://somedomain.com/foo.cgi?name=foo&passwd=bar')

but I got kicked out by the Python interpreter. I wonder somebody
knows the syntax of triggering a hyperlink? Thanks in advance!

Muddy Coder

Like others have said, if you want a browser window, use the
'webbrowser' module. If you're looking to simply trigger a GET/POST
without the UI aspect, then you'll probably want urllib or urllib2.

Thanks,

Jeff
mcjeff.blogspot.com
 

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

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top