Results of executing hyperlink in script

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Wed Jan 28 22:00:25 EST 2009


En Wed, 28 Jan 2009 20:49:14 -0200, Muddy Coder <cosmo_general at yahoo.com>  
escribió:

> My previous post got a many helps from the people, and I tested what
> they suggested. Since this topic maybe needed in future, so I drop
> these lines below to help the future programmers. The methods worked
> as below:
>
> 1. This method was suggested by Cameron Laird:
>
>       os.system("start %s" % URL)
>
> It works. But, if the URL contains character &, it will fail. For

> 2. The best way is to use urllib2, suggested by Ron Barak, my code is
> below:
>
> import urllib2
> source = urllib2.urlopen(URL).read()
> print source

Note that both methods are essencially different. The first one opens a  
browser window, and it's up to the user what to do after the initial  
request is done -- if this is what you want, the webbrowser module is  
better suited for that task.
The second one is a pure programming interfase - the Python script is in  
control, and the user isn't involved at all.

-- 
Gabriel Genellina




More information about the Python-list mailing list