How use urllib.urlopen()?

Bjorn Pettersen pbjorn at
Fri Dec 22 19:38:29 CET 2000


#! /usr/local/bin/python
print "Content-type: text/html"

then your program. If that doesn't work, try:

 - make sure the script is executable
 - change the extension of your script to .cgi

If none of that works try the following:
 - put the following in tt.cgi
 - make tt.cgi executable
 - create yyy.txt and make it world writable (important)
 - run it from your web-browser
 - look at what went wrong (it should be in yyy.txt).

echo "Content-type: text/html"
/home/bjorn/public_html/ >> yyy.txt 2>&1
#echo "<h1>hello world</h1>"

Hope this gets you on your way.

-- bjorn

Gustaf Liljegren wrote:

> Can't get the urlopen() function to work. I have a script on a UNIX web
> server that should go to another webpage when the user clicks a button. To
> isolate the problem, I made a test script:
> #!/usr/local/bin/python
> import urllib
> u = urllib.urlopen("")
> print
> When running this I get HTTP 500 - Internal server error. :-(
> What's missing?
> Gustaf

More information about the Python-list mailing list