Here are the examples of the python api app.managers.request.HttpRequest.request taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
3 Examples
3
View Complete Implementation : md5_crypto.py
Copyright GNU General Public License v3.0
Author : offensive-hub
Copyright GNU General Public License v3.0
Author : offensive-hub
@staticmethod
def decrypt(text: str):
for api in Md5Crypto.Api.all():
r = HttpRequest.request(api['url'] + text)
if r is None:
continue
try:
r_json = r.json()
except json.decoder.JSONDecodeError:
continue
result = api['get_result'](r_json)
if result is not None:
return result
Log.error('md5: unable to decrypt: ' + text)
return None
0
View Complete Implementation : html_parser.py
Copyright GNU General Public License v3.0
Author : offensive-hub
Copyright GNU General Public License v3.0
Author : offensive-hub
def _parse(self, url: str = None, html: str = None) -> (dict, str):
"""
Make an HTML/URL parsing by processing ALL found tags
:param url: The url to parse (or None)
:param html: The html page to parse as string (or None)
:return: dictionary of tags, cookies
"""
self.url = None
self.base_url = None
cookies = ''
if url is not None:
self.url = url
url_parsed = urlparse(url)
self.url_scheme = str(url_parsed.scheme)
self.base_url = self.url_scheme + '://' + str(url_parsed.netloc)
r = HttpRequest.request(url)
if r is None:
return None
try:
html = r.json()
Log.warning('Trying to parse a json with HTML parser!')
except ValueError:
html = r.text
if r.headers is not None:
for k in r.headers.keys():
if k == 'Set-Cookie' or k == 'set-cookie' or k == 'Set-cookie':
cookies = r.headers.get('Set-Cookie')
break
sorted_html, errors = tidy_docameent(html) # Sort html (and fix errors)
self.feed(sorted_html)
return self.tags, cookies
0
View Complete Implementation : mac_manufacturer.py
Copyright GNU General Public License v3.0
Author : offensive-hub
Copyright GNU General Public License v3.0
Author : offensive-hub
def _update_manufacturer_dict(self):
manufacturer_response = HttpRequest.request(MacManufacturer._MANUFACTURERS_URL)
if manufacturer_response is None:
return
if manufacturer_response.text is None:
return
manufacturer_dict = dict()
manufacturer_list = manufacturer_response.text.splitlines()
for manufacturer in manufacturer_list:
if len(manufacturer) < 1:
continue
if manufacturer[0] == '#':
continue
manufacturer_details = manufacturer.split('\t')
i = 0
mac = None
lookup_dict = {
MacManufacturer._MANUFACTURERS_DETAIL_DICT[1]: None,
MacManufacturer._MANUFACTURERS_DETAIL_DICT[2]: None,
MacManufacturer._MANUFACTURERS_DETAIL_DICT[3]: None
}
for detail in manufacturer_details:
if detail == '':
continue
if i == 0:
# MAC address
mac_detail = detail.split('/')
if len(mac_detail) == 2:
# The mac has a sub mask, so the dict key is the first n bits
sub_mask = int(mac_detail[1]) / 4
mac_sub_mask = floor(sub_mask + (sub_mask / 2))
mac = mac_detail[0][0:mac_sub_mask]
elif len(mac_detail) == 1:
# The mac has not a sub mask
mac = mac_detail[0]
else:
Log.error("Wrong mac address: " + str(detail))
break
if i >= len(MacManufacturer._MANUFACTURERS_DETAIL_DICT):
Log.error("Wrong manufacturer details: " + str(manufacturer_details))
break
lookup_dict[MacManufacturer._MANUFACTURERS_DETAIL_DICT[i]] = detail
i += 1
if mac is None:
Log.error("Wrong manufacturer details: " + str(manufacturer_details))
continue
manufacturer_dict[mac] = lookup_dict
if len(manufacturer_dict) > 0:
self._manufacturer_dict = manufacturer_dict
JsonSerializer.set_dictionary(self._manufacturer_dict, MacManufacturer._MANUFACTURERS_JSON)