getting a URL
johnvert at my-deja.com
johnvert at my-deja.com
Thu Jun 8 14:35:24 EDT 2000
Hello,
As an exercise I'm trying to write a simple cgi script that will get the
source code of an html file and echo it to the screen. Here's what I
have:
import cgi, urllib
(snip)
url = urllib.urlopen("http://www.server.org/foo.html")
print "<pre>"
print cgi.escape(url.read()),
print "</pre>"
But nothing is printed. The problematic line seems to be:
url = urllib.urlopen("http://www.server.org/foo.html")
But the URL I gave it in the actual program is correct. I tried a few.
If I run this on the shell (it's meant to be a cgi) it raises IOError
sayin 'network unreachable'. What could be wrong? Also, why does
execution stop at:
print "<pre>"
Why isn't the rest (print "</pre>" among others) printed?
Thanks,
-- John
Sent via Deja.com http://www.deja.com/
Before you buy.
More information about the Python-list
mailing list