python - 使用 xmpppy 通过 Jabber 发送 XHTML

标签 python xmpppy

我正在尝试使用 xmpppy 通过 Jabber(到 Google Talk)发送 XHTML(一个超链接),但找不到一个好的工作示例...我试过这个:

http://intertwingly.net/blog/2007/08/09/Sending-XHTML-over-Jabber

但是没有用……有什么想法吗??

提前致谢!

中号

最佳答案

这是我用来构造 XHTML 消息的一个小块(感谢 Thomas Perl/Jabberbot.py)

    html_message = "<b>Test!</b>"

    plain_message = re.sub(r'<[^>]+>', '', html_message)
    message = xmpp.protocol.Message(body=plain_message)
    html = xmpp.Node('html', {'xmlns': 'http://jabber.org/protocol/xhtml-im'})
    html.addChild(node=xmpp.simplexml.XML2Node("<body xmlns='http://www.w3.org/1999/xhtml'>" + html_message.encode('utf-8') + "</body>")) 
    message.addChild(node=html)

关于python - 使用 xmpppy 通过 Jabber 发送 XHTML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3310750/

相关文章:

python - Python 中 global 的替代方案

python - 通过Python + xmpppy 发送消息 : AttributeError in minimal example

python - Jabber bot - 如何获得联系人的可用性?

python - Python 上的 XMPP 响应 Gtalk,但不响应 Hangouts

python - 使用 Python 从上下文中自动选择标签

python - 将 python 时间对象插入 MySQL 表

python - url_for 中的 flask jinja 宏变量

python - 如何断开我的 XMPPPY 客户端对象

python - 与另一端的连接以非干净的方式丢失