Okay, sorry to bother you again, but urllib2.urlopen doesn't seem to be working in Django. If I put the following script in cgi-bin:
#!/usr/bin/python
print "Content-type:text/html\n"
from urllib2 import urlopen, URLError
out = ""
try:
urlopen("http://google.com")
except URLError, e:
print "<p>"+str(e.reason)+"</p>"
print "<p>done</p>"
The output is '<p>done</p>'. But if I use this in Django (views.py):
from django.shortcuts import HttpResponse
from urllib2 import urlopen, URLError
def sample (request):
out = ""
try:
urlopen("http://google.com")
except URLError, e:
out += "<p>"+str(e.reason)+"</p>"
out += "<p>done</p>"
return HttpResponse(out)
The output is '<p>unable to select on socket</p><p>done</p>'.
Is there any reason this might be happening? These are located here and here respectively