Testing for Internet Connection

Grant Edwards grante at visi.com
Tue Jul 15 17:46:49 CEST 2008


>> If you can define exactly what you mean by "internet connection", the
>> test for it becomes correspondingly easier.

> Well, really I just need to figure out if I am able to connect
> to one site. That site is dictionary.com.

Then use urllib2 to try to fetch a page from dictionary.com. If
it works, you're "connected".  If it fails, you're not.  The
most straight-forward way to find out if you can do X is to try
to do X.

-- 
Grant Edwards                   grante             Yow! if it GLISTENS,
                                  at               gobble it!!
                               visi.com            



More information about the Python-list mailing list