Sample Script to Publish a blog Post #Python


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://sriramoracle.wordpress.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. 

Published by