@@ -0,0 +1,1673 @@
+from BeautifulSoup import BeautifulSoup as bs%0Aimport jieba.analyse%0A%0A%0Aclass HtmlFeatures :%0A%0A    def _is_mobile_adapted(self):%0A        viewport = self.html_bs.head.find(name='meta', attrs=%7B'name':'viewport'%7D)%0A        if viewport:%0A            self.mobile_friendly = True%0A        else:%0A            self.mobile_friendly = False%0A    %0A    def _include_video(self) :%0A%0A        video_suffix = %5B'.SWF', '.FLV', '.MP4', '.3GP', '.OGG', '.MPEG4', '.WEBM'%5D%0A        if %5BTrue for item in video_suffix if item in str(self.body_bs)%5D:%0A            self.video = True%0A        elif self.html_bs.find('vedio'):%0A            self.video = True%0A        else :%0A            self.video = False%0A            %0A    def _extract_words_cnt(self):%0A        bs = self.body_bs%0A     %0A        #remove useless content%0A        %5Bs.extract() for s in bs('script')%5D%0A        %5Ba.extract() for a in bs('a')%5D%0A%0A        #remove tags%0A        self.body = '%5Cn'.join(i.string for i in bs.fetch() if i.string)%0A%0A        self.words_count = len(self.body)%0A%0A%0A    def _extract_n_keywords(self):%0A%0A        self.keywords = jieba.analyse.extract_tags(self.body, topK=self.kw_cnt, allowPOS=('n'))%0A        %0A    %0A    def __init__(self, html, keyword_count):%0A        self.html_bs = bs(html)%0A        self.body_bs = self.html_bs.body%0A        self.kw_cnt = keyword_count%0A%0A        self._is_mobile_adapted()%0A        self._include_video()%0A        self._extract_words_cnt()%0A        self._extract_n_keywords()%0A%0A    def get_features(self) :%0A        return %7B%0A            'include_video': self.video,%0A            'is_mobile_friendly': self.mobile_friendly,%0A            'words_count': self.words_count,%0A            'topn_key_words': self.keywords%0A        %7D%0A

add simple html feature extractor