本文整理汇总了Python中urllib.URLError方法的典型用法代码示例。如果您正苦于以下问题:Python urllib.URLError方法的具体用法?Python urllib.URLError怎么用?Python urllib.URLError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类urllib
的用法示例。
在下文中一共展示了urllib.URLError方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process_targeting_form
# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import URLError [as 别名]
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
示例2: setup_apps
# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import URLError [as 别名]
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)
示例3: _fetch_url
# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import URLError [as 别名]
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()