Select to view content in your preferred language

Validating web URLs in a database file

779
1
02-16-2012 11:24 AM
RandyKreuziger
Frequent Contributor
We have high quality PDF maps for most of our Wildlife Areas.  The feature class we put out in our web applications contains a field with a hyper link to these PDFs.  Not all Wildlife Areas have a PDF map but I'd like to programmatically populate the field and then NULL out the field if there is no PDF map at that web location.  Does anyone know how to test the validity of a web URL in Python?   Thanks
Tags (2)
0 Kudos
1 Reply
KevinHibma
Esri Regular Contributor
Im sure there are better ways to do this, but heres a quick and dirty way:

import urllib2
try:
  urllib2.urlopen('http://hsfdsda.com')
except:
  print "didnt work"
0 Kudos