- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试通过 XMLRPC 在我的 WordPress 博客中插入 HTML 内容,但如果我插入 HTML - 我收到错误:
raise TypeError, "cannot marshal %s objects" % type(value) TypeError: cannot marshal objects
如果我使用漂白剂(用于清洁标签)-我的页面上会出现带有标签的文本
我的代码
# coding: utf-8
import requests
from bs4 import BeautifulSoup
import bleach
from wordpress_xmlrpc import Client, WordPressPost
from wordpress_xmlrpc.methods import posts
xmlrpc_url = "http://site.ru/xmlrpc.php"
wp_username = "user"
wp_password = "123"
blog_id = ""
client = Client(xmlrpc_url, wp_username, wp_password, blog_id)
url = "https://lifehacker.ru/2016/08/30/finansovye-sovety-dlya-molodyx-par/"
r = requests.get(url)
soup = BeautifulSoup(r.content)
post_title = soup.find("h1")
post_excerpt = soup.find("div", {"class", "single__excerpt"})
for tag in post_excerpt():
for attribute in ["class", "id", "style"]:
del tag[attribute]
post_content = soup.find("div", {"class","post-content"})
for tag in post_content():
for attribute in ["class", "id", "style"]:
del tag[attribute]
post = WordPressPost()
post.title = post_title.text
post.content = post_content
post.id = client.call(posts.NewPost(post))
post.post_status = 'publish'
client.call(posts.EditPost(post.id, post))
如何在我的 WordPress 博客中插入已解析的 HTML 内容?
最佳答案
在漂白并解决问题后使用 .replace。
我的代码
...
post_content_insert = bleach.clean(post_content)
post_content_insert = post_content_insert.replace('<','<')
post_content_insert = post_content_insert.replace('>','>')
post = WordPressPost()
post.title = post_title.text
post.content = post_content_insert
post.id = client.call(posts.NewPost(post))
关于Python - 使用 xmlrpc api 插入 HTML 内容 tp WordPress,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39235760/
我正在为 get tp.address_from 和 tp.address_to 构建一个 View ,但我无法正常工作。这是我正在处理的查询: SELECT `tp`.`address_fr
我在 https://github.com/spakai/threadpool_future 中有 3 个针对此代码 ThreadPool 的单元测试用例 class ThreadPoolTes
我的应用程序有一个缓存值的方法。我需要第二种方法来检查类型 T 的泛型参数是否实现了 IEnumerable 而不是实现了 IList。如果答案是肯定的,该方法应该执行 .ToList 并将其转换回
如何理解 template bool is_array = true 是 template bool is_array = true 的部分特化? 这是相关的 code snippet: #inclu
P2P全称peer-to-peer,可定义为:以非集中方式使用分布式资源来完成关键任务的一类系统和应用。 定义中有两点解释一下: 资源――包括计算能力、数据、网络带宽等;关键任务――分布式计算、
WPS功能是路由器与无线设备(手机、笔记本等)之间的一种加密方式;而PIN码是WPS的一种验证方式,相当于无线WiFi的密码。当连接无线WiFi提示输入PIN码连接时,说明无线路由器上启用了wps功
1、进入虚拟服务器设置界面 登录路由器管理界面,点击“应用管理”,进入应用中心,如下图: 找到虚拟服务器,点击“进入”,如下: 2、添加映射条目及规则 点击“添加”按钮,如下:
第一步:启用打印服务器功能 登录路由器管理界面,在网络共享>>打印服务器中,确认打印服务器状态为在线,如下图: 第二步:安装打印服务器控制程序 1、解压控制程序 将下载好
据BleepingComputer消息,近日安全研究人员对当下9种流行WiFi 路由器进行测试分析,共发现了226个漏洞,其中包括一些路由器刚刚更新使用了最新的固件。 这些测试的路由器分别来自
本文实例讲述了TP(thinkPHP)框架多层控制器和多级控制器的使用。分享给大家供大家参考,具体如下: 多层控制器的目录结构是这样的: ├─Controller 访问控制器 │ 
TP-Link TL-WR847N路由器设置好连不上网怎么办?最近一位用户反馈说,自己的路由器型号是TP-Link TL-WR847N,按照说明书设置好路由器之后,发现连不上网,这是怎么回事呢?下面
TP-Link TL-WR880N路由器管理员默认密码是多少?对于TP-Link TL-WR880N路由器,有V1、V2、V3共3个硬件版本,不同的硬件版本,默认密码是不同的。下面就给大家分享TP-
我可以在 reducer 输出中传递值列表吗? 编码 :- 公共(public)类 XXX 扩展了 Reducer > 我需要输出为“文本列表”值。 可以通过 Map Reduce 吗? 最佳答案 您
我正在尝试从 Skoda Rapid 2009 模型中的各种 ECU 中查找 DTC。 我正在使用 OBDLink SX(elm 327 芯片)和 Putty(类似于 super 终端) https:
我正在使用 QT Creater 1.0.0。和 QT 4.5.0 LGPL 许可证。 我想用 QT 开发一个可以在 windows mobile 6.0 上运行的应用程序。 我在 QT 中创建了一个
我的窗口有三个 iframe,我可以切换到层次结构中的前两个框架并执行操作,但无法将上下文切换到第三个框架。 我可以切换到 FWin0 和 Content0 框架并设置/获取屏幕中的值,但无法将上
当我们讨论分布式系统的性能时,我们使用术语 tp50、tp90、tp99.99 TPS。有人可以解释一下这些是什么意思吗? 最佳答案 tp90 是满足 90% 请求的最长时间。想象一下你有时间: 10
I am playing around with hyperledger-sawtooth. I have installed the sawtooth in ubuntu machine but i
我正在尝试构建一个 html 表单并将其连接到一个正在执行查询并将信息插入 mysql 数据库的 php 文件。 这是我的 html 代码: Add Record Form MGMT I
我有一个输入。我需要验证该值是否以“T”开头,后跟数字或“TP”开头,后跟数字接受的值:T12345 或 TP12345 我的 JavaScript 代码 var ip_value = documen
我是一名优秀的程序员,十分优秀!