【问题标题】:ENML to plain text converter for Python用于 Python 的 ENML 到纯文本转换器
【发布时间】:2016-05-16 00:01:30
【问题描述】:

从 javascript (enml.js) 移植 enml 库

evernote-sdk-js 的 ENML.PlainTextOfENML 对我有用 我想为 Python 找到这个工具的一个很好的端口。

我尝试使用这些库,但出现错误:

https://github.com/CarlLee/ENML_PY
ImportError: 没有名为 bs4 的模块

https://github.com/wanasit/enml-py
2013 年 2 月,没有文件,
ImportError: No module named internals

例如
我想得到:

任何对 Apple 产品的液体损坏都会使您的保修失效。

来自

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd"><en-note>any sort of liquid damage to an Apple product will void your warranty.</en-note>

我要使用 enml 的代码部分:
视图.py

title_contents = {}
for note in result_list.notes:
    content = note_store.getNoteContent(auth_token, 
                                        note_store.getNote(note.guid, 
                                        True,False, False, False).guid)
    title_contents[note.title] = content

enter code herereturn render_to_response('oauth/callback.html', {'notebooks': notebooks, 
                                                  'result_list': result_list, 
                                                  'title_contents': title_contents})

回调.html

    .....
    <ul>
      {% for title, content in title_contents.items %}
        <li><b>{{ title }}</b><br>{{ content }}</li>
      {% endfor %}
    </ul>

【问题讨论】:

标签: python django evernote


【解决方案1】:

这种组合可以完成所有需要的事情:

from fenml import ENMLToHTML
# the fenml.py is my internal fork of the 
# https://github.com/CarlLee/ENML_PY/blob/master/__init__.py 
# with slightly modified code. 
from bs4 import BeautifulSoup
import html2text
....
title_contents[note.title] = html2text.html2text(BeautifulSoup(ENMLToHTML(content)).prettify())

【讨论】:

    猜你喜欢
    • 2015-12-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多