コード例 #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
ファイル: getUrls.py プロジェクト: qz267/pylinktester
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
ファイル: testUrls.py プロジェクト: qz267/pylinktester
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)