test(data): created a function to parse url to dict

This function creates a dict of the components of a url.

MR !4
This commit is contained in:
2022-01-28 09:37:50 +09:30
parent 8292b0a6cf
commit 45cb623758

View File

@ -16,6 +16,32 @@ class Data:
response = json.loads(entry['message'])['message']
return response
def parse_url(self, url):
request_protocol = re.match("^[http|file]+s?", url).group(0)
url_id = hashlib.md5(bytes(url, 'utf-8')).hexdigest()
if re.match("^http.*", url) is not None:
domain = re.match(r'^([a-z]+[\.|a-z|]+)',url.replace(request_protocol + '://', '')).group(0)
request_path = url.replace(request_protocol + '://','').replace(domain, '')[1:]
elif re.match("^file.*", url) is not None:
domain = 'file'
request_path = url.replace(request_protocol + '://','')[1:]
return {
'url_id': url_id,
'request_protocol': request_protocol,
'domain': domain,
'request_path': request_path
}
def __init__(self):
caps = DesiredCapabilities.CHROME