Python urllib.URLError() Examples
The following are 3
code examples of urllib.URLError().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
urllib
, or try the search function
.
Example #1
Source File: jf-web.py From jawfish with MIT License | 5 votes |
def process_targeting_form(): global BASE_RESPONSE, REQ_TOTAL, METHOD, GOAL_TEXT, TARGET, ADDR,\ OTHER_VARIABLES, VULN_VAR url_string = window.location.href url_string = unquote( url_string ) try: TARGET = ((url_string.split('TARGET='))[1].split('&ADDR')[0]) result_out('[+]\tTarget %s acquired!' % TARGET) ADDR = ((url_string.split('&ADDR='))[1].split('&VULN_VAR')[0]) if ADDR[0] == '/': ADDR = ADDR[1:] result_out('[+]\tPath %s acquired!' % ADDR) VULN_VAR = ((url_string.split('&VULN_VAR='))[1].split('&METHOD')[0]) result_out('[+]\tPotentially vulnerable variable %s registered!' % VULN_VAR) METHOD = (((((url_string.split('&METHOD='))[1].split('&GOAL_TEXT')[0]) == 'post') and 1) or 0) result_out('[+]\tUsing method [%s] for GREAT success' % ((METHOD and 'post') or 'get')) OTHER_VARIABLES = {} GOAL_TEXT = url_string.split('&GOAL_TEXT=')[1] result_out('[+]\tAttempting to gain a base heuristic...') OTHER_VARIABLES[VULN_VAR] = 'AAAA' try: BASE_RESPONSE = urllib.urlopen('http://%s/%s' % (TARGET, ADDR), timeout=10) except urllib.URLError: BASE_RESPONSE = '404' if (BASE_RESPONSE.lower().find('not found') != -1 or BASE_RESPONSE.lower().find('404') != -1): result_out('404 or \'not found\' or timeout....are you sure this is OK?') result_out('\npage text:\n\n') result_out(BASE_RESPONSE) skip_line() result_out('lets try it anyway, you crazy cat') return True except: result_out('targeting argument FAIL\n\n') return False
Example #2
Source File: pavement.py From cartoview with BSD 2-Clause "Simplified" License | 5 votes |
def setup_apps(options): from cartoview.app_manager.helpers import (create_direcotry, change_path_permission) try: f = urlopen(TEST_DATA_URL) zip_ref = zipfile.ZipFile(BytesIO(f.read())) create_direcotry(APPS_DIR) if not os.access(APPS_DIR, os.W_OK): change_path_permission(APPS_DIR) zip_ref.extractall(APPS_DIR) zip_ref.close() except urllib2.HTTPError as e: print ("HTTP Error:", e.code) except urllib2.URLError as e: print ("URL Error:", e.reason)
Example #3
Source File: dzh.py From kquant_data with BSD 2-Clause "Simplified" License | 5 votes |
def _fetch_url(self): try: r = urllib data = r.read() self.f = io.StringIO(data) self._fetched = True except urllib.URLError: return self.fetch_next_server()