support joint accounts
This commit is contained in:
parent
5747a98541
commit
921409ebbc
1 changed files with 19 additions and 4 deletions
|
|
@ -35,10 +35,11 @@ class LoginPage(BasePage):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class CDNBasePage(BasePage):
|
class CDNBasePage(BasePage):
|
||||||
def get_from_js(self, pattern, end):
|
def get_from_js(self, pattern, end, is_list=False):
|
||||||
"""
|
"""
|
||||||
find a pattern in any javascript text
|
find a pattern in any javascript text
|
||||||
"""
|
"""
|
||||||
|
value = None
|
||||||
for script in self.document.xpath('//script'):
|
for script in self.document.xpath('//script'):
|
||||||
txt = script.text
|
txt = script.text
|
||||||
if txt is None:
|
if txt is None:
|
||||||
|
|
@ -48,8 +49,22 @@ class CDNBasePage(BasePage):
|
||||||
if start < 0:
|
if start < 0:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
txt = txt[start+len(pattern):start+txt[start+len(pattern):].find(end)+len(pattern)]
|
while 1:
|
||||||
return txt
|
if value is None:
|
||||||
|
value = ''
|
||||||
|
else:
|
||||||
|
value += ','
|
||||||
|
value += txt[start+len(pattern):start+txt[start+len(pattern):].find(end)+len(pattern)]
|
||||||
|
|
||||||
|
if not is_list:
|
||||||
|
break
|
||||||
|
|
||||||
|
txt = txt[start+len(pattern)+txt[start+len(pattern):].find(end):]
|
||||||
|
|
||||||
|
start = txt.find(pattern)
|
||||||
|
if start < 0:
|
||||||
|
break
|
||||||
|
return value
|
||||||
|
|
||||||
def get_execution(self):
|
def get_execution(self):
|
||||||
return self.get_from_js("name: 'execution', value: '", "'")
|
return self.get_from_js("name: 'execution', value: '", "'")
|
||||||
|
|
@ -66,7 +81,7 @@ class AccountsPage(CDNBasePage):
|
||||||
def get_list(self):
|
def get_list(self):
|
||||||
accounts = []
|
accounts = []
|
||||||
|
|
||||||
txt = self.get_from_js('_data = new Array(', ');')
|
txt = self.get_from_js('_data = new Array(', ');', is_list=True)
|
||||||
|
|
||||||
if txt is None:
|
if txt is None:
|
||||||
raise BrokenPageError('Unable to find accounts list in scripts')
|
raise BrokenPageError('Unable to find accounts list in scripts')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue