Python網頁正文結構化提取庫:jparser 0.0.11釋出

pythontab發表於2017-05-18

jparser 0.0.11 釋出了。jparser是一個python庫,用於網頁轉碼,也就是從html原始碼中抽取正文的結構化資料:文字段落和圖片。目前主要針對新聞資訊類頁面進行了優化。主要更新內容如下:

Python網頁正文結構化提取庫:jparser 0.0.11釋出

Bug fix:


title提取錯誤


正文區域判斷失誤bad case


li標籤內容遺漏


線上測試Demo:http://jparser.duapp.com/


程式碼例項:

import urllib2
from jparser import PageModel
html = urllib2.urlopen("http://www.pythontab.com").read().decode('gb18030')
pm = PageModel(html)
result = pm.extract()
print "**title**"
print result['title']
print "==content=="
for x in result['content']:
    if x['type'] == 'text':
        print x['data']
    if x['type'] == 'image':
        print "[IMAGE]", x['data']['src']


相關文章