Sriram Sanka

Databases | Cloud | Infrastructure | Security |

Sample Script to Publish a blog Post #Python

Posted by Sriram Sanka on March 29, 2023

Sample Script to Publish a blog Post Using Python

This post is Auto published using Python script attached below. #Python

import json
from wordpress_xmlrpc import Client, WordPressPost
from wordpress_xmlrpc.methods.posts import NewPost
import getpass
password = getpass.getpass(prompt='Password: ', stream=None)  //Blog Login Password 
def auto_blog_post(blog_content,blog_excerpt,blog_status):
    id = 'sriramoracle'   //User Name
    url = 'https://ramoradba.com/xmlrpc.php'
    wp = Client(url, id, password)
    post = WordPressPost()
    post.post_status = blog_status
    post.title = blog_excerpt
    post.content = blog_content
    post.excerpt = blog_excerpt
    post.terms_names = {
        "post_tag": ['Python'],
        "category": ['Python']
    }
    wp.call(NewPost(post))
auto_blog_post('Sample Script to Publish a blog Post Using Python ','Sample Script to Publish a blog Post ' ,'publish')  //publish will publish the Post, Draft is the default mode. 

Sorry, the comment form is closed at this time.

 

Discover more from Sriram Sanka

Subscribe now to keep reading and get access to the full archive.

Continue reading