I not sure if you quite understand the task @wavic,Scapy would add a whole new level of complexity that may not be needed.
It can be use to add some features if build this,but may also not be needed.
To give n rough example when i say wrapper around Requests.
Can also bring in stuff from requests.utils eg as i do with
which has a lot features that not so good documented.
It can be use to add some features if build this,but may also not be needed.
To give n rough example when i say wrapper around Requests.
Can also bring in stuff from requests.utils eg as i do with
url.user_agent
,which has a lot features that not so good documented.
import requests class Url: def __init__(self, url): try: self.req = requests.get(url) self.server = self.req.headers['Server'] self.date = self.req.headers['Date'] self.user_agent = requests.utils.default_headers() except requests.exceptions.ConnectionError as e: print("Wrong domains,chek spelling") def __getattr__(self, attr): return "API has not that name,check spelling" @property def header(self): '''May be needed later''' pass @header.setter def header(self): '''May be needed later''' passUse:
>>> url = Url('https://www.python.org99') Wrong domains,chek spelling >>> url = Url('https://www.python.org') >>> # all Requests build in constants will be under "req" >>> url.req.status_code 200 >>> url.req.encoding 'utf-8' >>> # New constants added >>> url.server 'nginx' # Miss-spelling will call __getattr__ >>> url.serverrr 'API has not that name,check spelling' >>> url.date 'Fri, 01 Feb 2019 01:50:02 GMT' >>> url.user_agent {'User-Agent': 'python-requests/2.21.0', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} >>> url.user_agentt 'API has not that name,check spelling' >>>