(self, html)
return extracted
Extract data from usual semantic tags.
Extract data from usual semantic tags.
Extract data from usual semantic tags .
def extract(self, html):
        "Extract data from usual semantic tags."
        extracted = {}
        soup = init_bs(html)
        
        for tag, dest, max_to_store in self.extract_string:
            for found in soup.find_all(tag)[:max_to_store] or []:
                if dest not in extracted:
                    extracted[dest] = []
                extracted[dest].append(u" ".join(found.strings))

        for tag, dest, attribute, max_to_store in self.extract_attr:
            for found in soup.find_all(tag)[:max_to_store] or []:
                if attribute in found.attrs:
                    if dest not in extracted:
                        extracted[dest] = []
                    extracted[dest].append(found[attribute])

        return extracted
def extract ( self , html ) : extracted = { } soup = init_bs ( html ) for tag , dest , max_to_store in self . extract_string : for found in soup . find_all ( tag ) [ : max_to_store ] or [ ] : if dest not in extracted : extracted [ dest ] = [ ] extracted [ dest ] . append ( u" " . join ( found . strings ) ) for tag , dest , attribute , max_to_store in self . extract_attr : for found in soup . find_all ( tag ) [ : max_to_store ] or [ ] : if attribute in found . attrs : if dest not in extracted : extracted [ dest ] = [ ] extracted [ dest ] . append ( found [ attribute ] ) return extracted