使用python在wordpress上发布文章的方法

首先安装 python-wordpress-xmlrpc

pip3 install python-wordpress-xmlrpc

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# -*- coding: utf-8 -*-
import json
from wordpress_xmlrpc import Client, WordPressPost
from wordpress_xmlrpc.methods.posts import NewPost
 
id = 'user'
password = 'pwd'
 
url = 'http://wordpress.url/xmlrpc.php'
 
wp = Client(url, id, password)
 
post = WordPressPost()
post.post_status = 'publish'
post.title = '新的文章'
post.content = '这里是文章内容,不错噢'
post.excerpt = '这里是摘抄样式示例'
post.terms_names = {
"post_tag": ['Python'],
"category": ['Python']
}
 
wp.call(NewPost(post))

  

相关阅读  Python100天学习计划:第97天:图像库 PIL(二)

发表评论

您的电子邮箱地址不会被公开。