CGI oddness with urllib

Ian McMeans imcmeans at home.com
Tue Jul 2 05:31:41 EDT 2002


I want a CGI script to load a page with urllib.open(), do some parsing, and
then do some output. The script works fine as a command-line script, but
fails when I have it running as a CGI script.

The CGI script works (it can do other stuff okay, like load files off my
hard drive and do output) but it's unable to do urllib.open() when the exact
same code works when run from the console.

Anyone know what's happening? Is it restricted execution or something?

Here's the code:

#!F:\Python22\python.exe
import urllib, cgi, cgitb
cgitb.enable()

print "Content-Type: text/html"     # HTML is following
print                               # blank line, end of headers

print urllib.urlopen('http://www.google.com/').read()





More information about the Python-list mailing list