use cElementTree and elementtidy as default encoders, and added wrappers to ElementParser and HTMLParser if they are missing
This commit is contained in:
parent
3d0c80c323
commit
51433d6549
4 changed files with 115 additions and 28 deletions
|
|
@ -20,6 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
import time
|
||||
from logging import warning
|
||||
from html5lib import treebuilders, HTMLParser
|
||||
|
||||
from weboob.tools.browser import Browser
|
||||
from weboob.backends.aum.exceptions import AdopteWait
|
||||
|
|
@ -34,6 +35,13 @@ from weboob.backends.aum.pages.login import LoginPage, RedirectPage, BanPage, Er
|
|||
from weboob.backends.aum.pages.edit import EditPhotoPage, EditPhotoCbPage, EditAnnouncePage, EditDescriptionPage, EditSexPage, EditPersonalityPage
|
||||
from weboob.backends.aum.pages.wait import WaitPage
|
||||
|
||||
class AdopteParser(HTMLParser):
|
||||
def __init__(self):
|
||||
HTMLParser.__init__(self, tree=treebuilders.getTreeBuilder("dom"))
|
||||
|
||||
def parse(self, data):
|
||||
return HTMLParser.parse(self, data, encoding='iso-8859-1')
|
||||
|
||||
class AdopteUnMec(Browser):
|
||||
DOMAIN = 'www.adopteunmec.com'
|
||||
PROTOCOL = 'http'
|
||||
|
|
@ -66,6 +74,7 @@ class AdopteUnMec(Browser):
|
|||
}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
kwargs['parser'] = AdopteParser
|
||||
Browser.__init__(self, *args, **kwargs)
|
||||
self.my_id = 0
|
||||
|
||||
|
|
|
|||
|
|
@ -19,12 +19,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
"""
|
||||
|
||||
from weboob.tools.browser import BrowserIncorrectPassword, BasePage
|
||||
from weboob.capabilities.messages import Message
|
||||
|
||||
class DLFPPage(BasePage):
|
||||
def is_logged(self):
|
||||
forms = self.document.getElementsByTagName('form')
|
||||
for form in forms:
|
||||
if form.getAttribute('id') == 'formulaire':
|
||||
for form in self.document.getiterator('form'):
|
||||
if form.attrib.get('id', None) == 'formulaire':
|
||||
return False
|
||||
|
||||
return True
|
||||
|
|
@ -38,9 +38,7 @@ class LoginPage(DLFPPage):
|
|||
raise BrowserIncorrectPassword()
|
||||
|
||||
def has_error(self):
|
||||
plist = self.document.getElementsByTagName('p')
|
||||
for p in plist:
|
||||
p = p.childNodes[0]
|
||||
if hasattr(p, 'data') and p.data.startswith(u'Vous avez rentré un mauvais mot de passe'):
|
||||
for p in self.document.getiterator('p'):
|
||||
if p.text and p.text.startswith(u'Vous avez rentré un mauvais mot de passe'):
|
||||
return True
|
||||
return False
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue