diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2021-03-23 00:38:25 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2021-03-23 00:38:25 +0300 |
commit | 92ad3c75765b23f238c4254855eae7a76c2f2770 (patch) | |
tree | 12594d01676d267d8138c007fb70f8f889ee9451 | |
parent | 074df3e7abe5402f889d89bba767e3680ec07817 (diff) |
e3372: initial xml parsing
-rw-r--r-- | e3372.py | 24 |
1 files changed, 19 insertions, 5 deletions
@@ -8,10 +8,24 @@ class E3372: pass def auth(self): - soup = self._request("webserver/SesTokInfo") - print(soup) + response = self.request("webserver/SesTokInfo") - def _request(self, endpoint: str, method='GET'): - url = f"http://{self.ip}/api/{endpoint}" + cookie = response.find('SesInfo').get_text() + token = response.find('TokInfo').get_text() + + self.headers['Cookie'] = cookie + self.headers['__RequestVerificationToken'] = token + self.headers['Content-Type'] = 'text/xml' + + def device_information(self): + response = self.request('device/information') + print(response) + + def device_signal(self): + response = self.request('device/signal') + print(response) + + def request(self, endpoint: str, method='GET'): + url = f'http://{self.ip}/api/{endpoint}' r = requests.get(url) if method == 'GET' else requests.post(url) - return BeautifulSoup(r.text, "lxml")
\ No newline at end of file + return BeautifulSoup(r.text, 'xml').find('response')
\ No newline at end of file |