Пример #1
0
def getsource(url):
	
	req, opener = getRequest.getRequest(url)
	try:
		urlopen = opener.open(req, timeout = 10)
		source = urlopen.read()
		return source
	except Exception:
	    testUrls.testUrls(url)
Пример #2
0
def getsource(url):
	
	req, opener = getRequest.getRequest(url)
	try:
		urlopen = opener.open(req, timeout = 10)
		source = urlopen.read()
		return source
	except Exception:
	    testUrls.testUrls(url)
Пример #3
0
def testUrls(url, repeat = 3):
	ti = time.strftime('%Y-%m-%d %H:%M:%S ',time.localtime(time.time()))
	if url is not None:
		req, opener = getRequest.getRequest(url)
		try:
			urlopen = opener.open(req, timeout = 30)
		except urllib2.HTTPError, ex:
			if(repeat > 0):
				testUrls(url, repeat - 1)
			else:
				log(str(ex), ti, url)
		except urllib2.URLError, ex:
			if(repeat > 0):
				testUrls(url, repeat - 1)
			else:
				log(str(ex), ti, url)
Пример #4
0
def testUrls(url, repeat=3):
    ti = time.strftime('%Y-%m-%d %H:%M:%S ', time.localtime(time.time()))
    if url is not None:
        req, opener = getRequest.getRequest(url)
        try:
            urlopen = opener.open(req, timeout=10)
        except urllib2.HTTPError, ex:
            if (repeat > 0):
                testUrls(url, repeat - 1)
            else:
                log(str(ex), ti, url)
        except urllib2.URLError, ex:
            if (repeat > 0):
                testUrls(url, repeat - 1)
            else:
                log(str(ex), ti, url)