当前位置: 首页>>代码示例>>Python>>正文


Python parse.parse方法代码示例

本文整理汇总了Python中urllib.parse.parse方法的典型用法代码示例。如果您正苦于以下问题:Python parse.parse方法的具体用法?Python parse.parse怎么用?Python parse.parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在urllib.parse的用法示例。


在下文中一共展示了parse.parse方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import parse [as 别名]
def __init__(self, var):
        #: The original string that comes through with the variable
        self.original = var
        #: The operator for the variable
        self.operator = ''
        #: List of safe characters when quoting the string
        self.safe = ''
        #: List of variables in this variable
        self.variables = []
        #: List of variable names
        self.variable_names = []
        #: List of defaults passed in
        self.defaults = {}
        # Parse the variable itself.
        self.parse()
        self.post_parse() 
开发者ID:fniephaus,项目名称:alfred-gmail,代码行数:18,代码来源:variable.py

示例2: parse_args

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import parse [as 别名]
def parse_args():
    # parse the arguments
    parser = argparse.ArgumentParser(epilog='\tExample: \r\npython ' + sys.argv[0] + " -d google.com")
    parser.error = parser_error
    parser._optionals.title = "OPTIONS"
    parser.add_argument('-d', '--domain', help="Domain name to enumerate it's subdomains", required=True)
    parser.add_argument('-b', '--bruteforce', help='Enable the subbrute bruteforce module', nargs='?', default=False)
    parser.add_argument('-p', '--ports', help='Scan the found subdomains against specified tcp ports')
    parser.add_argument('-v', '--verbose', help='Enable Verbosity and display results in realtime', nargs='?', default=False)
    parser.add_argument('-t', '--threads', help='Number of threads to use for subbrute bruteforce', type=int, default=30)
    parser.add_argument('-e', '--engines', help='Specify a comma-separated list of search engines')
    parser.add_argument('-o', '--output', help='Save the results to text file')
    return parser.parse_args() 
开发者ID:kp625544,项目名称:subtake,代码行数:15,代码来源:sublist3r.py

示例3: saveFailedTest

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import parse [as 别名]
def saveFailedTest(data, expect, filename):
    """Upload failed test images to web server to allow CI test debugging.
    """
    commit = runSubprocess(['git', 'rev-parse',  'HEAD'])
    name = filename.split('/')
    name.insert(-1, commit.strip())
    filename = '/'.join(name)
    host = 'data.pyqtgraph.org'

    # concatenate data, expect, and diff into a single image
    ds = data.shape
    es = expect.shape

    shape = (max(ds[0], es[0]) + 4, ds[1] + es[1] + 8 + max(ds[1], es[1]), 4)
    img = np.empty(shape, dtype=np.ubyte)
    img[..., :3] = 100
    img[..., 3] = 255

    img[2:2+ds[0], 2:2+ds[1], :ds[2]] = data
    img[2:2+es[0], ds[1]+4:ds[1]+4+es[1], :es[2]] = expect

    diff = makeDiffImage(data, expect)
    img[2:2+diff.shape[0], -diff.shape[1]-2:-2] = diff

    png = makePng(img)
    
    conn = httplib.HTTPConnection(host)
    req = urllib.urlencode({'name': filename,
                            'data': base64.b64encode(png)})
    conn.request('POST', '/upload.py', req)
    response = conn.getresponse().read()
    conn.close()
    print("\nImage comparison failed. Test result: %s %s   Expected result: "
          "%s %s" % (data.shape, data.dtype, expect.shape, expect.dtype))
    print("Uploaded to: \nhttp://%s/data/%s" % (host, filename))
    if not response.startswith(b'OK'):
        print("WARNING: Error uploading data to %s" % host)
        print(response) 
开发者ID:SrikanthVelpuri,项目名称:tf-pose,代码行数:40,代码来源:image_testing.py

示例4: parse_args

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import parse [as 别名]
def parse_args():
    # parse the arguments
    parser = argparse.ArgumentParser(epilog='\tExample: \r\npython ' + sys.argv[0] + " -d google.com")
    parser.error = parser_error
    parser._optionals.title = "OPTIONS"
    parser.add_argument('-d', '--domain', help="Domain name to enumerate it's subdomains", required=True)
    parser.add_argument('-b', '--bruteforce', help='Enable the subbrute bruteforce module', nargs='?', default=False)
    parser.add_argument('-p', '--ports', help='Scan the found subdomains against specified tcp ports')
    parser.add_argument('-v', '--verbose', help='Enable Verbosity and display results in realtime', nargs='?', default=False)
    parser.add_argument('-t', '--threads', help='Number of threads to use for subbrute bruteforce', type=int, default=30)
    parser.add_argument('-e', '--engines', help='Specify a comma-separated list of search engines')
    parser.add_argument('-o', '--output', help='Save the results to text file')
    parser.add_argument('-n', '--no-color', help='Output without color', default=False, action='store_true')
    return parser.parse_args() 
开发者ID:aboul3la,项目名称:Sublist3r,代码行数:16,代码来源:sublist3r.py

示例5: imgurUpload

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import parse [as 别名]
def imgurUpload(file_path, image_data=None):
	""" Upload the given image to Imgur. 
	
	Arguments:
		file_path: [str] Path to the image file.

	Keyword arguments:
		image_data: [bytes] Read in image in JPG, PNG, etc. format.

	Return:
		img_url: [str] URL to the uploaded image.
	"""

	# Read the image if image data was not given
	if image_data is None:
		
		# Open the image in binary mode
		f = open(file_path, "rb")
		image_data = f.read()


	# Encode the image
	b64_image = base64.standard_b64encode(image_data)


	# Upload the image
	headers = {'Authorization': 'Client-ID ' + CLIENT_ID}
	data = {'image': b64_image, 'title': 'test'} # create a dictionary.

	request = urllib2.Request(url="https://api.imgur.com/3/upload.json", 
		data=urllib.urlencode(data).encode("utf-8"), headers=headers)
	response = urllib2.urlopen(request).read()


	# Get URL to image
	parse = json.loads(response)
	img_url = parse['data']['link']
	

	return img_url 
开发者ID:CroatianMeteorNetwork,项目名称:RMS,代码行数:42,代码来源:ImgurUpload.py

示例6: parse

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import parse [as 别名]
def parse(self):
        """Parse the variable.

        This finds the:
            - operator,
            - set of safe characters,
            - variables, and
            - defaults.

        """
        var_list = self.original
        if self.original[0] in URIVariable.operators:
            self.operator = self.original[0]
            var_list = self.original[1:]

        if self.operator in URIVariable.operators[:2]:
            self.safe = URIVariable.reserved

        var_list = var_list.split(',')

        for var in var_list:
            default_val = None
            name = var
            if '=' in var:
                name, default_val = tuple(var.split('=', 1))

            explode = False
            if name.endswith('*'):
                explode = True
                name = name[:-1]

            prefix = None
            if ':' in name:
                name, prefix = tuple(name.split(':', 1))
                prefix = int(prefix)

            if default_val:
                self.defaults[name] = default_val

            self.variables.append(
                (name, {'explode': explode, 'prefix': prefix})
            )

        self.variable_names = [varname for (varname, _) in self.variables] 
开发者ID:fniephaus,项目名称:alfred-gmail,代码行数:46,代码来源:variable.py


注:本文中的urllib.parse.parse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。