(function(){
if(''){
if (prompt('请输入文章密码') !== ''){
alert('密码错误!');
history.back();
}
}
})();
var NexT = window.NexT || {};
var CONFIG = {
hostname: new URL('https://kechenhh.gitee.io').hostname,
root: '/',
scheme: 'Gemini',
version: '7.7.0',
exturl: false,
sidebar: {"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},
copycode: {"enable":false,"show_result":false,"style":null},
back2top: {"enable":true,"sidebar":false,"scrollpercent":false},
bookmark: {"enable":false,"color":"#222","save":"auto"},
fancybox: false,
mediumzoom: false,
lazyload: false,
pangu: false,
comments: {"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},
algolia: {
appID: '',
apiKey: '',
indexName: '',
hits: {"per_page":10},
labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
},
localsearch: {"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},
path: 'search.xml',
motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}
};
// https://hexo.io/docs/variables.html
CONFIG.page = {
sidebar: "",
isHome: false,
isPost: true
};
python使用xmlrpc自动发布文章到wordpress | 我的博客
.use-motion .brand,
.use-motion .menu-item,
.sidebar-inner,
.use-motion .post-block,
.use-motion .pagination,
.use-motion .comments,
.use-motion .post-header,
.use-motion .post-body,
.use-motion .collection-header { opacity: initial; }
.use-motion .site-title,
.use-motion .site-subtitle {
opacity: initial;
top: initial;
}
.use-motion .logo-line-before i { left: initial; }
.use-motion .logo-line-after i { right: initial; }
python使用xmlrpc自动发布文章到wordpress
发表于
2020-01-17
更新于
2020-12-19
分类于
Python
模块的使用方法看 https://python-wordpress-xmlrpc.readthedocs.io/en/latest/
安装:
带有自定义栏目字段的发布文章代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 from wordpress_xmlrpc import Client, WordPressPostfrom wordpress_xmlrpc.methods.posts import GetPosts, NewPostfrom wordpress_xmlrpc.methods.users import GetUserInfofrom wordpress_xmlrpc.methods import postsfrom wordpress_xmlrpc.methods import taxonomiesfrom wordpress_xmlrpc import WordPressTermfrom wordpress_xmlrpc.compat import xmlrpc_clientfrom wordpress_xmlrpc.methods import media, postsimport sysreload(sys) sys.setdefaultencoding('utf-8' ) wp = Client('http://您的域名/xmlrpc.php' , '后台账号' , '后台密码' ) post = WordPressPost() post.title = '文章标题' post.content = '文章内容' post.post_status = 'publish' post.terms_names = { 'post_tag' : ['test' , 'firstpost' ], 'category' : ['Introductions' , 'Tests' ] } post.custom_fields = [] post.custom_fields.append({ 'key' : 'price' , 'value' : 3 }) post.custom_fields.append({ 'key' : 'ok' , 'value' : '天涯海角' }) post.id = wp.call(posts.NewPost(post))</pre>
带有特色图像缩略图的发布文章
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 from wordpress_xmlrpc import Client, WordPressPostfrom wordpress_xmlrpc.methods.posts import GetPosts, NewPostfrom wordpress_xmlrpc.methods.users import GetUserInfofrom wordpress_xmlrpc.methods import postsfrom wordpress_xmlrpc.methods import taxonomiesfrom wordpress_xmlrpc import WordPressTermfrom wordpress_xmlrpc.compat import xmlrpc_clientfrom wordpress_xmlrpc.methods import media, postsimport sysreload(sys) sys.setdefaultencoding('utf-8' ) wp = Client('http://您的域名/xmlrpc.php' , '后台账号' , '后台密码' ) filename = './my.jpg' data = { 'name' : 'picture.jpg' , 'type' : 'image/jpeg' , } with open(filename, 'rb' ) as img: data['bits' ] = xmlrpc_client.Binary(img.read()) response = wp.call(media.UploadFile(data)) attachment_id = response['id' ] post = WordPressPost() post.title = '文章标题' post.content = '文章正文' post.post_status = 'publish' post.terms_names = { 'post_tag' : ['test' , 'firstpost' ], 'category' : ['Introductions' , 'Tests' ] } post.thumbnail = attachment_id post.id = wp.call(posts.NewPost(post))
单独创建新的分类和标签
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 from wordpress_xmlrpc import Client, WordPressPostfrom wordpress_xmlrpc import WordPressTermfrom wordpress_xmlrpc.methods import taxonomiesimport sysreload(sys) sys.setdefaultencoding('utf-8' ) wp = Client('http://您的域名/xmlrpc.php' , '后台账号' , '后台密码' ) tag = WordPressTerm() tag.taxonomy = 'post_tag' tag.name = 'My New Tag12' tag.slug = 'bieming12' tag.id = wp.call(taxonomies.NewTerm(tag)) cat = WordPressTerm() cat.taxonomy = 'category' cat.name = 'cat1' cat.slug = 'bieming2' cat.id = wp.call(taxonomies.NewTerm(cat)) parent_cat = client.call(taxonomies.GetTerm('category' , 20 )) child_cat = WordPressTerm() child_cat.taxonomy = 'category' child_cat.parent = parent_cat.id child_cat.name = 'My Child Category' child_cat.slug = 'beidongdui' child_cat.id = wp.call(taxonomies.NewTerm(child_cat))
window.addEventListener('tabs:register', () => {
let activeClass = CONFIG.comments.activeClass;
if (CONFIG.comments.storage) {
activeClass = localStorage.getItem('comments_active') || activeClass;
}
if (activeClass) {
let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
if (activeTab) {
activeTab.click();
}
}
});
if (CONFIG.comments.storage) {
window.addEventListener('tabs:click', event => {
if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
let commentClass = event.target.classList[1];
localStorage.setItem('comments_active', commentClass);
});
}
一键复制
编辑
Web IDE
原始数据
按行查看
历史