;ň r!”Ac@sÇdklZdklZdklZdkZdkZdklZdefd„ƒYZ e Z ydk Z eZ Wndk Z nXde ifd„ƒYZe p ed joe iƒndS( (sTag(s HTMLParser(s entitydefsN(s ParseErrorsCustomizedParsercBsŞtZdZdZdZdZeZeZeZ eZ eZ eZ eZ eeeedd„Zd„Zd„Zd„Zd„Zd „Zd „Zd „Zd „ZRS( s This class parse the HTML, but in a customized way: it only parse the tags and attributes specified in 'parse_tags' and 'parse_attrs', skipping others. NOTE: This Class tries to parse broken HTML, but it's something difficult due the number of non-capable people doing HTML. Maybe you need to correct the HTML using regular expressions or something like that. One thing is to close one tag when you expect another, in this case, the parser assumes that there is a need to close that tag and goes down through the last opened tags, closing them until it matches the wanted tags. This can lead to a problem when you close a tag that was not opened (in my case, it was !), then you need to remove this tag. s4Gustavo Sverzut Barbieri s $Rev: 255 $icCs˘ti|ƒtdƒg|_dg|_d|_|pdddddd g|_|p d d d g|_|pd g|_ ||_ |pdg|_ dS(s8 parse_tags: a list of tag names to be parsed. Tags outside this list will be skipped. parse_attrs: a list of attributes to be parsed. Attributes outside this list will be skipped. must_close_tags: a list of tags that should be closed before other tag start. Ie: many document doesn't close
c1 c2 c3
c4 c5 c6
sŐ test link
c1 c2 c3
c4 c5 c6
shtmlscdatastestschildrensbodysashrefs link.htmlslinkstablescolss3strstdsc1sc2sc3sc4sc5sc6sselectsoptionsvalues1sop1s2sop2sop3s parse_tagss parse_attrsscolspansmust_close_tags( sselfsi1si2sTagsosCustomizedParserscpsfeeds get_structuresp1sp2(sself((sU/mnt/gmirror/ports/textproc/py-tvgrab/work/pytvgrab-lib-0.5.1/lib/customizedparser.pyssetUps4 "   - <'3      !!cCs3t|iƒ}|t|iƒjp t|‚dS(N(sstrsselfsp1svsosAssertionError(sselfsv((sU/mnt/gmirror/ports/textproc/py-tvgrab/work/pytvgrab-lib-0.5.1/lib/customizedparser.pystest01scCs3t|iƒ}|t|iƒjp t|‚dS(N(sstrsselfsp2svsosAssertionError(sselfsv((sU/mnt/gmirror/ports/textproc/py-tvgrab/work/pytvgrab-lib-0.5.1/lib/customizedparser.pystest02‘s(s__name__s __module__s__doc__ssetUpstest01stest02(((sU/mnt/gmirror/ports/textproc/py-tvgrab/work/pytvgrab-lib-0.5.1/lib/customizedparser.pysCustomizedParser_UnitTests  q s__main__(stagsTags HTMLParsershtmlentitydefss entitydefssmessagesi18nsgrabexceptionss ParseErrorsCustomizedParsersFalsesusing_unittest2s unittest2sunittestsTruesTestCasesCustomizedParser_UnitTests__name__smain( susing_unittest2s entitydefssunittests ParseErrorsTags HTMLParsersCustomizedParser_UnitTestsi18nsmessagesCustomizedParser((sU/mnt/gmirror/ports/textproc/py-tvgrab/work/pytvgrab-lib-0.5.1/lib/customizedparser.pys?(s      Ţ   |