Найти - Пользователи
Полная версия: UrlLib в Python 2.7.3 и метод timeout
Начало » Python для новичков » UrlLib в Python 2.7.3 и метод timeout
1
BossBox
Понимаю, вопрос не много странный, но я не смог найти на его ответ..

Как применить timeout в urllib (Python 2.7.3), пробовал так:

urllib.urlopen(decodeURL, timeout = 1)

Не выходит.
terabayt
Плохо искали.
нужно проверять, что если timeout не помог и сайт не открылся
import urllib2
import socket
try:
    urllib2.urlopen("http://example.com", timeout = 1)
except urllib2.URLError, e:
	print "There was an error: ", e
except socket.timeout, e:
    print "There was an error: ", e
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB