(self, html)
return {'titles':titles, 'descriptions':descriptions, 'videos':videos}
Extract data from HTML5 semantic tags.
Extract data from HTML5 semantic tags.
Extract data from HTML5 semantic tags .
def extract(self, html):
        "Extract data from HTML5 semantic tags."
        titles = []
        descriptions = []
        videos = []
        soup = init_bs(html)
        for article in soup.find_all('article') or []:
            title = article.find('h1')
            if title:
                titles.append(u" ".join(title.strings))
            desc = article.find('p')
            if desc:
                descriptions.append(u" ".join(desc.strings))

        for video in soup.find_all('video') or []:
            for source in video.find_all('source') or []:
                if 'src' in source.attrs:
                    videos.append(source['src'])

        return {'titles':titles, 'descriptions':descriptions, 'videos':videos}
def extract ( self , html ) : titles = [ ] descriptions = [ ] videos = [ ] soup = init_bs ( html ) for article in soup . find_all ( 'article' ) or [ ] : title = article . find ( 'h1' ) if title : titles . append ( u" " . join ( title . strings ) ) desc = article . find ( 'p' ) if desc : descriptions . append ( u" " . join ( desc . strings ) ) for video in soup . find_all ( 'video' ) or [ ] : for source in video . find_all ( 'source' ) or [ ] : if 'src' in source . attrs : videos . append ( source [ 'src' ] ) return { 'titles' : titles , 'descriptions' : descriptions , 'videos' : videos }