Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.python
CGI with URL problem
rodmc
2/11/2008 1:21:00 PM
-- sorry if this has shown up twice, but my browser crashed and ended
up posting the message when I hit the space bar for some odd reason.
Also it was not quite ready.
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 CGI 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 the CGI version:
from urllib2 import urlopen as urlopen
def urlexists(url):
path="
http://x.y.z/wiki/index.php?title=...
sock = urlopen(path)
page=sock.read()
if "There is currently no text in this page" in page:
return True
else:
return False
Ammended IDLE version:
from urllib2 import urlopen as urlopen
import os,sys
def urlexists(url):
path="
http://x.y.z/wiki/index.php?title=...
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")
2 Answers
Ralf Schoenian
2/13/2008 4:29:00 AM
0
rodmc schrieb:
> -- sorry if this has shown up twice, but my browser crashed and ended
> up posting the message when I hit the space bar for some odd reason.
> Also it was not quite ready.
>
> 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 CGI 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 the CGI version:
>
> from urllib2 import urlopen as urlopen
>
> def urlexists(url):
> path="
http://x.y.z/wiki/index.php?title=...
> sock = urlopen(path)
> page=sock.read()
> if "There is currently no text in this page" in page:
> return True
> else:
> return False
>
> Ammended IDLE version:
>
> from urllib2 import urlopen as urlopen
> import os,sys
>
> def urlexists(url):
> path="
http://x.y.z/wiki/index.php?title=...
> 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")
Are you using the same user in your cgi script and within IDLE?
Ralf Schoenian
rodmc
2/14/2008 2:11:00 PM
0
Thanks for your reply, no one is running locally on my PC and the
other as the default user which occurs when the script is run through
a browser.
Best,
rod
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
CGI with URL problem
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password