Handling urllib2's return of badstatusline(line)?
--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------
Take control of your privacy with Proton's trusted, Swiss-based, secure services.
Choose what you need and safeguard your digital life:
Mail: https://go.getproton.me/SH1CU
VPN: https://go.getproton.me/SH1DI
Password Manager: https://go.getproton.me/SH1DJ
Drive: https://go.getproton.me/SH1CT
Music by Eric Matyas
https://www.soundimage.org
Track title: Mysterious Puzzle
--
Chapters
00:00 Handling Urllib2'S Return Of Badstatusline(Line)?
01:04 Answer 1 Score 3
01:11 Accepted Answer Score 6
01:18 Thank you
--
Full question
https://stackoverflow.com/questions/1725...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #python27 #exceptionhandling #return #urllib2
#avk47
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------
Take control of your privacy with Proton's trusted, Swiss-based, secure services.
Choose what you need and safeguard your digital life:
Mail: https://go.getproton.me/SH1CU
VPN: https://go.getproton.me/SH1DI
Password Manager: https://go.getproton.me/SH1DJ
Drive: https://go.getproton.me/SH1CT
Music by Eric Matyas
https://www.soundimage.org
Track title: Mysterious Puzzle
--
Chapters
00:00 Handling Urllib2'S Return Of Badstatusline(Line)?
01:04 Answer 1 Score 3
01:11 Accepted Answer Score 6
01:18 Thank you
--
Full question
https://stackoverflow.com/questions/1725...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #python27 #exceptionhandling #return #urllib2
#avk47
ACCEPTED ANSWER
Score 6
import httplib
...
def internet_on():
try:
urllib2.urlopen("http://google.co.uk/", timeout = 10)
return True
except (IOError, httplib.HTTPException):
return False
ANSWER 2
Score 3
except httplib.BadStatusLine as e:
return False