admin管理员组文章数量:1323379
We are working on a platform that gets news from various sources and runs some NLP analysis on it.
We have the backbone of the backend down, we're now trying to output our results on a feed. Since articles are gathered using our automated engine, WP posts containing the articles and NLP analysis will be generated programmatically, not manually by users. We picked Wordpress as our CMS.
So far, I've had success with creating posts using this library (/), which I could use to post data to Wordpress at the end of my data pipeline.
client = Client(url, username, password)
post = WordPressPost()
post.title = 'Elon Musk discovers a new element'
post.content = 'Lets look at how Elon Musk is actually Tony Stark.'
post.terms_names = {
'post_tag': ['AI', 'musk'],
'category': ['Technology', 'Chemistry']
post.post_status = 'publish'
post.id = client.call(posts.NewPost(post))
I read however that XML-RPC was outdated, and may lead to issues down the line. In my research, I found this also (/), but it's much less documented.
What are some options here? What else can I use to post data from Python to WP databases.
We are working on a platform that gets news from various sources and runs some NLP analysis on it.
We have the backbone of the backend down, we're now trying to output our results on a feed. Since articles are gathered using our automated engine, WP posts containing the articles and NLP analysis will be generated programmatically, not manually by users. We picked Wordpress as our CMS.
So far, I've had success with creating posts using this library (https://pypi/project/python-wordpress-xmlrpc/), which I could use to post data to Wordpress at the end of my data pipeline.
client = Client(url, username, password)
post = WordPressPost()
post.title = 'Elon Musk discovers a new element'
post.content = 'Lets look at how Elon Musk is actually Tony Stark.'
post.terms_names = {
'post_tag': ['AI', 'musk'],
'category': ['Technology', 'Chemistry']
post.post_status = 'publish'
post.id = client.call(posts.NewPost(post))
I read however that XML-RPC was outdated, and may lead to issues down the line. In my research, I found this also (https://pypi/project/wordpress-api/), but it's much less documented.
What are some options here? What else can I use to post data from Python to WP databases.
Share Improve this question edited Sep 14, 2020 at 10:39 Tom J Nowell♦ 61k7 gold badges79 silver badges148 bronze badges asked Sep 14, 2020 at 10:21 PetePete 113 bronze badges 1- 1 I would keep in mind that using a WP library in python will probably make your life harder, not easier. A generic REST APII library would be more useful. If it's a software recommendation you're looking for though you'd need to post on the software recommendation stack – Tom J Nowell ♦ Commented Sep 14, 2020 at 10:40
1 Answer
Reset to default 1Use the REST API at /wp-json
, there are endpoints for retrieving posts that you can POST
to.
You will need a plugin installed to provide authentication, I recommend OAuth2.
Then, you can use an OAuth2 and a REST API library in python. You do not need to use a WordPress specific library.
本文标签: databaseSending posts from Python to WordPress
版权声明:本文标题:database - Sending posts from Python to WordPress 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742121419a2421722.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论