Testing for connection to a website
alexnbryan at gmail.com
Wed Jul 16 02:58:49 CEST 2008
Timothy Grant wrote:
> On Tue, Jul 15, 2008 at 3:48 PM, Alexnb <alexnbryan at gmail.com> wrote:
>> Alexnb wrote:
>> > Okay, I already made this post, but it kinda got lost. So anyway I need
>> > figure out how to test if the user is able to connect to a specific
>> > website. Last time I got pointed to the urllib2 page, but if I do
>> > urlopen() and and am not connected, the program stops. So I don't know
>> > that was what you guys wanted me to do, but I don't think so, you guys
>> > smarter than that. So, how can I test for connection to a website.
>> Just for anyone looking this up later here is code that works :)
>> from urllib2 import *
>> import urllib2
>> e = ''
>> req = urllib2.Request('http://www.dictionary.com')
>> response = urlopen(req)
>> except HTTPError, e:
>> print e.code
>> except URLError, e:
>> print e.reason
>> if e == '':
>> print "good to go"
>> View this message in context:
>> Sent from the Python - python-list mailing list archive at Nabble.com.
> I'm glad to see you found the old post and implemented the code suggested
> Stand Fast,
> tjg. [Timothy Grant]
well I can tel you it didn't work for me. In fact I didn't see the code you
posted on there, I ended up figuring it out on my own with a little help
from the missing manual for urllib2. Also, being rude is kinda stupid
because you don't have to help in the first place...
View this message in context: http://www.nabble.com/Testing-for-connection-to-a-website-tp18473382p18478103.html
Sent from the Python - python-list mailing list archive at Nabble.com.
More information about the Python-list