Fix TP-Link get auth token

This commit is contained in:
Paulus Schoutsen 2016-03-07 08:29:05 -08:00
parent 1e97d31711
commit 5222c19b4c

View File

@ -337,9 +337,11 @@ class Tplink4DeviceScanner(TplinkDeviceScanner):
response = requests.get(url, headers={'cookie': cookie}) response = requests.get(url, headers={'cookie': cookie})
try: try:
result = re.search('window.parent.location.href = ' + result = re.search(r'window.parent.location.href = '
r'"https?:\/\/.*\/(.*)\/userRpm\/Index.htm";', r'"https?:\/\/.*\/(.*)\/userRpm\/Index.htm";',
response.text) response.text)
if not result:
return False
self.token = result.group(1) self.token = result.group(1)
return True return True
except ValueError: except ValueError:
@ -370,8 +372,8 @@ class Tplink4DeviceScanner(TplinkDeviceScanner):
}) })
result = self.parse_macs.findall(page.text) result = self.parse_macs.findall(page.text)
if result: if not result:
self.last_results = [mac.replace("-", ":") for mac in result] return False
return True
return False self.last_results = [mac.replace("-", ":") for mac in result]
return True