From 92ad3c75765b23f238c4254855eae7a76c2f2770 Mon Sep 17 00:00:00 2001 From: Evgeny Zinoviev Date: Tue, 23 Mar 2021 00:38:25 +0300 Subject: e3372: initial xml parsing --- e3372.py | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'e3372.py') diff --git a/e3372.py b/e3372.py index 6cfa246..7c9e554 100644 --- a/e3372.py +++ b/e3372.py @@ -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 -- cgit v1.2.3