admin管理员组

文章数量:1323554

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
Add a comment  | 

1 Answer 1

Reset to default 1

Use 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