use ExpectedElementNotFound
This commit is contained in:
parent
abe75cb1b1
commit
bb1524b46a
1 changed files with 10 additions and 9 deletions
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from weboob.tools.browser import BasePage
|
from weboob.tools.browser import BasePage, ExpectedElementNotFound
|
||||||
|
|
||||||
from ..video import YoujizzVideo
|
from ..video import YoujizzVideo
|
||||||
|
|
||||||
|
|
@ -28,23 +28,24 @@ __all__ = ['IndexPage']
|
||||||
|
|
||||||
class IndexPage(BasePage):
|
class IndexPage(BasePage):
|
||||||
def iter_videos(self):
|
def iter_videos(self):
|
||||||
span_list = self.document.getroot().cssselect("span#miniatura")
|
div_id = 'span#miniatura'
|
||||||
|
span_list = self.document.getroot().cssselect(div_id)
|
||||||
if not span_list:
|
if not span_list:
|
||||||
return
|
raise ExpectedElementNotFound(div_id)
|
||||||
|
|
||||||
for span in span_list:
|
for span in span_list:
|
||||||
a = span.find('.//a')
|
a = span.find('.//a')
|
||||||
if a is None:
|
if a is None:
|
||||||
continue
|
raise ExpectedElementNotFound('%s.//a' % span)
|
||||||
url = a.attrib['href']
|
url = a.attrib['href']
|
||||||
_id = re.sub(r'/videos/(.+)\.html', r'\1', url)
|
_id = re.sub(r'/videos/(.+)\.html', r'\1', url)
|
||||||
|
|
||||||
thumbnail_url = span.find('.//img').attrib['src']
|
thumbnail_url = span.find('.//img').attrib['src']
|
||||||
|
|
||||||
title1 = span.cssselect('span#title1')
|
title1_selector = 'span#title1'
|
||||||
|
title1 = span.cssselect(title1_selector)
|
||||||
if title1 is None:
|
if title1 is None:
|
||||||
title = None
|
raise ExpectedElementNotFound(title1_selector)
|
||||||
else:
|
|
||||||
title = title1[0].text.strip()
|
title = title1[0].text.strip()
|
||||||
|
|
||||||
duration = 0
|
duration = 0
|
||||||
|
|
@ -58,4 +59,4 @@ class IndexPage(BasePage):
|
||||||
title=title,
|
title=title,
|
||||||
duration=duration,
|
duration=duration,
|
||||||
thumbnail_url=thumbnail_url,
|
thumbnail_url=thumbnail_url,
|
||||||
nsfw=True)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue