Handling urllib2's return of badstatusline(line)?
Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn
--
Track title: CC L Beethoven - Piano Sonata No 8 in C
--
Chapters
00:00 Question
01:20 Accepted answer (Score 6)
01:34 Answer 2 (Score 3)
01:44 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
--
Track title: CC L Beethoven - Piano Sonata No 8 in C
--
Chapters
00:00 Question
01:20 Accepted answer (Score 6)
01:34 Answer 2 (Score 3)
01:44 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