comparison adslstats.py @ 26:04874587fb6e

suppress new BeautifulSoup warning
author Daniel O'Connor <darius@dons.net.au>
date Sun, 12 Aug 2018 15:57:28 +0930
parents 7571c101a4ee
children 607111929e2e
comparison
equal deleted inserted replaced
25:7571c101a4ee 26:04874587fb6e
137 return stats 137 return stats
138 138
139 def authenticate(br, base, username, password): 139 def authenticate(br, base, username, password):
140 # Connect and authenticate 140 # Connect and authenticate
141 r = br.open(base) 141 r = br.open(base)
142 bs = bs4.BeautifulSoup(r) 142 bs = bs4.BeautifulSoup(r, 'lxml')
143 token = bs.head.find(lambda tag: tag.has_attr('name') and tag['name'] == 'CSRFtoken')['content'] 143 token = bs.head.find(lambda tag: tag.has_attr('name') and tag['name'] == 'CSRFtoken')['content']
144 #print('Got CSRF token ' + token) 144 #print('Got CSRF token ' + token)
145 145
146 usr = srp.User(username, password, hash_alg = srp.SHA256, ng_type = srp.NG_2048) 146 usr = srp.User(username, password, hash_alg = srp.SHA256, ng_type = srp.NG_2048)
147 uname, A = usr.start_authentication() 147 uname, A = usr.start_authentication()
164 return True 164 return True
165 165
166 def fillstats(br, base, stats): 166 def fillstats(br, base, stats):
167 # Fetch stats and parse 167 # Fetch stats and parse
168 r = br.open(base + '/modals/broadband-bridge-modal.lp') 168 r = br.open(base + '/modals/broadband-bridge-modal.lp')
169 bs = bs4.BeautifulSoup(r) 169 bs = bs4.BeautifulSoup(r, 'lxml')
170 if bs.find('div', 'login') != None: 170 if bs.find('div', 'login') != None:
171 return False 171 return False
172 172
173 # Helper function to extract data 173 # Helper function to extract data
174 def getvals(bs, text, mult = 1): 174 def getvals(bs, text, mult = 1):