# encoding : utf-8
from html2text import html2text
import os

def getbody(html):
    try:
        txt = html2text(html.decode('utf8'))
    except:
        txt = html2text(html.decode('gbk'))    
    try:
        txt = txt.encode('utf8').split('\n')
    except:
        txt = txt.encode('gbk').split('\n')
    for r in txt:
        r = r.strip()
        if r == '':continue
        elif r[0] == '[':pass
        elif r[-1] == ']':pass
        elif r[5:]<chr(127):pass
        elif r[0].isdigit() and r[2] > chr(127):yield r
        elif r[0] == '#' and r[1] != '#':yield r
        elif r[0] == '*' and r[1] == '*': yield r
        elif r[0] > chr(127):yield r
if __name__ == '__main__':
    url = "http://baby.sina.com.cn/edu/09/1303/0800133263.shtml"
    html = os.popen("curl --compressed %s" % url).read()
    print '\n'.join(getbody(html))
@@ -74,16 +74,31 @@
 (html):%0A
+    bodytxt=%5B%5D%0A
     try:
@@ -410,43 +410,157 @@
 '%5B':
-pass%0A        elif r%5B-1%5D == '%5D':pass
+%0A            if len(bodytxt) %3E= 5:break%0A            else:pass%0A        elif '%5D' in r%5B-4:%5D and len(bodytxt) %3C 5:pass%0A        elif r%5B:4%5D == '****':break
 %0A   
@@ -637,23 +637,33 @@
 hr(127):
-yield r
+bodytxt.append(r)
 %0A       
@@ -700,65 +700,215 @@
 '#':
-yield r%0A        elif r%5B0%5D == '*' and r%5B1
+%0A            try:%0A                if bodytxt%5B-1%5D%5B0%5D == '#':bodytxt=%5B%5D%0A                else:bodytxt.append(r)%0A            except:%0A                bodytxt.append(r)%0A        elif r%5B:2
 %5D == '*
+*
 ':
- yield r
+bodytxt.append(r)
 %0A   
@@ -937,107 +937,436 @@
 27):
-yield r%0Aif __name__ == '__main__':%0A    url = %22http://baby.sina.com.cn/edu/09/1303/0800133263.shtml%22
+bodytxt.append(r)%0A        elif r%5B0%5D == '#' and len(bodytxt) %3E= 5:break%0A    return '%5Cn'.join(bodytxt)%0Aif __name__ == '__main__':%0A    url = %22http://baby.sina.com.cn/edu/09/1303/0800133263.shtml%22%0A    #url = %22http://www.zaojiao.com/education/2007/1210/article_1308.html%22%0A    #url = %22http://news.163.com/09/0313/10/549ESDIR000136K8.html%22%0A    #url = %22http://wow.duowan.com/0903/100883030207.html%22%0A    #testweblist:zaojiao,sina,163,wow
 %0A   
@@ -1429,26 +1429,16 @@
   print 
-'%5Cn'.join(
 getbody(
@@ -1442,9 +1442,8 @@
 dy(html)
-)

添加并修正部分筛选语句，初步测试成功