fix crash on pagination
mechanize does not support embeded optgroups, so it crashes when parsing another form is the page
This commit is contained in:
parent
2cf8777f18
commit
9142f6cea2
2 changed files with 26 additions and 10 deletions
|
|
@ -18,6 +18,7 @@
|
||||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
|
import urllib
|
||||||
from urlparse import urlparse, parse_qs
|
from urlparse import urlparse, parse_qs
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
import re
|
import re
|
||||||
|
|
@ -155,7 +156,9 @@ class OperationsPage(BasePage):
|
||||||
if len(form) == 0:
|
if len(form) == 0:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
text = self.parser.tocleanstring(form[0])
|
form = form[0]
|
||||||
|
|
||||||
|
text = self.parser.tocleanstring(form)
|
||||||
m = re.search(u'(\d+) / (\d+)', text or '', flags=re.MULTILINE)
|
m = re.search(u'(\d+) / (\d+)', text or '', flags=re.MULTILINE)
|
||||||
if not m:
|
if not m:
|
||||||
return False
|
return False
|
||||||
|
|
@ -166,10 +169,15 @@ class OperationsPage(BasePage):
|
||||||
if cur == last:
|
if cur == last:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
self.browser.select_form(name='paginationForm')
|
inputs = {}
|
||||||
self.browser.set_all_readonly(False)
|
for elm in form.xpath('.//input[@type="input"]'):
|
||||||
self.browser['page'] = str(cur + 1)
|
key = elm.attrib['name']
|
||||||
self.browser.submit()
|
value = elm.attrib['value']
|
||||||
|
inputs[key] = value
|
||||||
|
|
||||||
|
inputs['page'] = str(cur + 1)
|
||||||
|
|
||||||
|
self.browser.location(form.attrib['action'], urllib.urlencode(inputs))
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
|
import urllib
|
||||||
from urlparse import urlparse, parse_qs
|
from urlparse import urlparse, parse_qs
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
import re
|
import re
|
||||||
|
|
@ -155,7 +156,9 @@ class OperationsPage(BasePage):
|
||||||
if len(form) == 0:
|
if len(form) == 0:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
text = self.parser.tocleanstring(form[0])
|
form = form[0]
|
||||||
|
|
||||||
|
text = self.parser.tocleanstring(form)
|
||||||
m = re.search(u'(\d+) / (\d+)', text or '', flags=re.MULTILINE)
|
m = re.search(u'(\d+) / (\d+)', text or '', flags=re.MULTILINE)
|
||||||
if not m:
|
if not m:
|
||||||
return False
|
return False
|
||||||
|
|
@ -166,10 +169,15 @@ class OperationsPage(BasePage):
|
||||||
if cur == last:
|
if cur == last:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
self.browser.select_form(name='paginationForm')
|
inputs = {}
|
||||||
self.browser.set_all_readonly(False)
|
for elm in form.xpath('.//input[@type="input"]'):
|
||||||
self.browser['page'] = str(cur + 1)
|
key = elm.attrib['name']
|
||||||
self.browser.submit()
|
value = elm.attrib['value']
|
||||||
|
inputs[key] = value
|
||||||
|
|
||||||
|
inputs['page'] = str(cur + 1)
|
||||||
|
|
||||||
|
self.browser.location(form.attrib['action'], urllib.urlencode(inputs))
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue