Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Check for internet connectivity:
- #Example 1
- import sys, time, urllib2
- print ("Checking internet activity")
- time.sleep (3.0)
- try:
- con = urllib2.urlopen('http://www.google.com/')
- data = con.read()
- print 'Checking for internet connectivity please wait ...'
- print 'Internet connectivity ... OK!'
- print 'Starting update script!'
- except:
- print 'No internet :('
- sys.exit()
- #Example 2
- #!/usr/bin/python2
- import urllib
- try :
- stri = "https://www.google.com"
- data = urllib.urlopen(stri)
- print "Connectivity to www found"
- except e:
- print "not connected" ,e
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement