Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def start_from_exchange(self, exchange):
"""
Start webtech on a single target from a HTTP request-response exchange as Object
"""
target = Target()
target.parse_http_response(exchange['response'])
target.parse_http_request(exchange['request'], replay=False)
return self.perform(target)
def start_from_url(self, url, headers={}, timeout=None):
"""
Start webtech on a single URL/target
Returns the report for that specific target
"""
timeout = timeout or self.timeout
target = Target()
parsed_url = urlparse(url)
if "http" in parsed_url.scheme:
# Scrape the URL by making a request
h = {'User-Agent': self.USER_AGENT}
h.update(headers)
target.scrape_url(url, headers=h, cookies={}, timeout=timeout)
elif "file" in parsed_url.scheme:
# Load the file and read it
target.parse_http_file(url)
else:
raise ValueError("Invalid scheme {} for URL {}. Only 'http', 'https' and 'file' are supported".format(parsed_url.scheme, url))
return self.perform(target)
def start_from_url(self, url, headers={}, timeout=None):
"""
Start webtech on a single URL/target
Returns the report for that specific target
"""
timeout = timeout or self.timeout
target = Target()
parsed_url = urlparse(url)
if "http" in parsed_url.scheme:
# Scrape the URL by making a request
h = {'User-Agent': self.USER_AGENT}
h.update(headers)
target.scrape_url(url, headers=h, cookies={}, timeout=timeout)
elif "file" in parsed_url.scheme:
# Load the file and read it
target.parse_http_file(url)
else:
raise ValueError("Invalid scheme {} for URL {}. Only 'http', 'https' and 'file' are supported".format(parsed_url.scheme, url))
return self.perform(target)
def start_from_exchange(self, exchange):
"""
Start webtech on a single target from a HTTP request-response exchange as Object
"""
target = Target()
target.parse_http_response(exchange['response'])
target.parse_http_request(exchange['request'], replay=False)
return self.perform(target)