def extract(self, html, pref_template_id=None):
        """Extract data from an html page.

        If pref_template_url is specified, the template with that url will be
        used first.
        """
        extraction_page = parse_extraction_page(self.token_dict, html)
        extraction_trees = self.extraction_trees
        if pref_template_id is not None:
            extraction_trees = sorted(
                self.extraction_trees,
                key=lambda x: x.template.id != pref_template_id)
        sel = Selector(text=html.body)
        for extraction_tree in extraction_trees:
            template_id = extraction_tree.template.id
            extracted = extraction_tree.extract(extraction_page)
            correctly_extracted = []
            for item in extracted:
                if (isinstance(item, ItemProcessor) or
                        not hasattr(self, 'validated')):
                    if hasattr(item, 'process'):
                        item = item.process(sel)
                else:
                    item = self.validated[template_id]([item])
                if item:
                    correctly_extracted.append(item)
            if len(correctly_extracted) > 0:
                return correctly_extracted, extraction_tree.template
        return None, None
Extract data from an html page.

        If pref_template_url is specified, the template with that url will be
        used first.
        
slybot/slybot/plugins/scrapely_annotations/extraction/extractors.py