python利用 xmlrpc操作WordPress自动发布文章
- wang
- 2024-05-07
- Python笔记
- 4浏览
- 0评论
# encoding:utf-8
import pymysql
import requests
import json
import base64
import requests
import base64
from datetime import datetime
import time
from wordpress_xmlrpc import Client, WordPressPost
from wordpress_xmlrpc.methods import posts
# 连接数据库
conn_weixin = pymysql.connect(
host='42.236.82.14',
user='weiji',
password='sWEms5TKewFtnfiC',
database='wcaiji',
charset='utf8mb4', )
cursor_weixin = conn_weixin.cursor(cursor=pymysql.cursors.DictCursor)
#取一条数据
sql= f''' select * from xiaohongshu_url where status=1 order by id asc limit 1 '''
cursor_weixin.execute(sql)
res = cursor_weixin.fetchone()
print(res['title'])
if res['wangzhan_id']==103:
wp = Client('https://www.seda.com/xmlrpc.php', 'w32ang', 'xiao23qiang1233')
post = WordPressPost()
post.title = res['title']
post.content = res['title']+res['imgs']+res['content_yuanma']
post.post_status = 'publish' # 文章状态,不写默认是草稿,private表示私密的,draft表示草稿,publish表示发布
post.terms_names = {
'category': ['手机应用'],
'category': ['软件仓库'],
}
post.id = wp.call(posts.NewPost(post))
print(post.id)
import pymysql
import requests
import json
import base64
import requests
import base64
from datetime import datetime
import time
from wordpress_xmlrpc import Client, WordPressPost
from wordpress_xmlrpc.methods import posts
# 连接数据库
conn_weixin = pymysql.connect(
host='42.236.82.14',
user='weiji',
password='sWEms5TKewFtnfiC',
database='wcaiji',
charset='utf8mb4', )
cursor_weixin = conn_weixin.cursor(cursor=pymysql.cursors.DictCursor)
#取一条数据
sql= f''' select * from xiaohongshu_url where status=1 order by id asc limit 1 '''
cursor_weixin.execute(sql)
res = cursor_weixin.fetchone()
print(res['title'])
if res['wangzhan_id']==103:
wp = Client('https://www.seda.com/xmlrpc.php', 'w32ang', 'xiao23qiang1233')
post = WordPressPost()
post.title = res['title']
post.content = res['title']+res['imgs']+res['content_yuanma']
post.post_status = 'publish' # 文章状态,不写默认是草稿,private表示私密的,draft表示草稿,publish表示发布
post.terms_names = {
'category': ['手机应用'],
'category': ['软件仓库'],
}
post.id = wp.call(posts.NewPost(post))
print(post.id)
本站文章除注明转载/出处外,均为本站原创或翻译。若要转载请务必注明出处,尊重他人劳动成果共创和谐网络环境。
转载请注明 : 文章转载自 » 纵马网 » Python笔记 » python利用 xmlrpc操作WordPress自动发布文章
上一篇:Python里面用SELENIUM接管已经打开的火狐浏览器的方式代码 (2024-04-14)
下一篇:没有了