當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。