URL in CGI problems

R

rodmc

Hi,

I am writing a small CGI app which tests if another webpage exists,
the pages are on a Wiki system. Anyway when I run the same function
(see below) from within IDLE it is ok, however when it is run from
within the CGI script I get a socket error::

"URLError:
reason = <socket.error instance>"

I am not quite sure what is causing this, is there a special way of
dealing with such things from within CHI script? I have pasted the
offending function below, along with only the import statement which
relates to that function.

Thanks in advance for any help.

Kind regards,

rod

From CGI version:

from urllib2 import urlopen as urlopen

def urlexists(url):
path="http://x.y.z/wiki/index.php?title="+url
sock = urlopen(path)
page=sock.read()
if "There is currently no text in this page" in page:
print "found"
return True
else:
return False


Ammended IDLE version:

from urllib2 import urlopen as urlopen
import os,sys

def urlexists(url):
path="http://www.peachbase.org/peachbase/index.php?title="+url
sock = urlopen(path)
page=sock.read()
if "There is currently no text in this page" in page:
print "found"
return True
else:
print "not found"
return False


if __name__=="__main__":
urlexists("cheese_test")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,270
Latest member
TopCryptoTwitterChannels_

Latest Threads

Top