python-wordpress-xmlrpc介绍
python-wordpress-xmlrpc 是一个开源的Python第三方库,借助于该开源库,我们可以实现利用Python代码为wordpress发布文章,于是学习该库成为我们实现自动发布文章一个重要步骤。该库的简介以及文档详见python-wordpress-xmlrpc
安装python-wordpress-xmlrpc
这个步骤在文档中已经交代了,我们只是做一下展示。
要从你的wordpress中使用Python爬虫,你首先需要为你的wordpress安装一个插件(wp-xmlrpc-modernization),如下图
安装完成后启用该插件。
接下来我们就需要安装Python的python-wordpress-xmlrpc库,这个库有Python2.x的版本,也有Python3.x的版本,我们开发环境使用的是Python3.5 于是我们安装Python3.x版本的
sudo pip3 install python-wordpress-xmlrpc
使用Python3版本的pip,需要使用pip3
至此我们的开发环境搭建完成。
使用python-wordpress-xmlrpc发布博文
示例代码:
#!/usr/bin/env python3
#-*- coding : utf-8 -*-
#导入第三方库
from wordpress_xmlrpc import Client,WordPressPost
from word