Fix author selection

This commit is contained in:
Florent 2013-01-11 15:27:35 +01:00
commit 0d11694605
2 changed files with 17 additions and 2 deletions

View file

@ -18,7 +18,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from .pages.article import ArticlePage
from .pages.article import ArticlePage, ActuPage
from .pages.flashactu import FlashActuPage
from weboob.tools.browser import BaseBrowser, BasePage
@ -33,6 +33,7 @@ class NewspaperFigaroBrowser(BaseBrowser):
"http://\w+.lefigaro.fr/flash-.*/(\d{4})/(\d{2})/(\d{2})/(.*$)": FlashActuPage,
"http://\w+.lefigaro.fr/bd/(\d{4})/(\d{2})/(\d{2})/(.*$)": FlashActuPage,
"http://\w+.lefigaro.fr/(?!flash-|bd|actualite).+/(\d{4})/(\d{2})/(\d{2})/(.*$)": ArticlePage,
"http://\w+.lefigaro.fr/actualite/(\d{4})/(\d{2})/(\d{2})/(.*$)": ActuPage,
"http://\w+.lefigaro.fr/actualite-.*/(\d{4})/(\d{2})/(\d{2})/(.*$)": ArticlePage,
"http://\w+.lefigaro.fr/": IndexPage,
}

View file

@ -26,7 +26,7 @@ class ArticlePage(GenericNewsPage):
def on_loaded(self):
self.main_div = self.document.getroot()
self.element_title_selector = "h1"
self.element_author_selector = "div.name>span"
self.element_author_selector = "span.auteur>a, span.auteur_long>div"
self.element_body_selector = "#article, div.article"
def get_body(self):
@ -68,3 +68,17 @@ class ArticlePage(GenericNewsPage):
txts[0].drop_tag()
element_body.tag = "div"
return self.parser.tostring(element_body)
class ActuPage(GenericNewsPage):
def on_loaded(self):
self.main_div = self.document.getroot()
self.element_title_selector = "h2"
self.element_author_selector = "div.name>span"
self.element_body_selector = ".block-text"
def get_body(self):
element_body = self.get_element_body()
try_remove_from_selector_list(self.parser, element_body, ['div'])
element_body.tag = "div"
return self.parser.tostring(element_body)