import os
from wordpress_xmlrpc import Client, WordPressPost
from wordpress_xmlrpc.methods import posts # NewPost

wp = Client(‘https://abdurrahmaanjanhangeer.wordpress.com/xmlrpc.php’,’acosecant’,’spaceship’)
post = WordPressPost()
post.title = ‘Send wordpress posts through python bot code’
directory = “C:\\irc”
if not os.path.exists(directory):
os.makedirs(directory)
filem = open(os.path.join(directory,”filewp.txt”), ‘r’)
wwp=filem.read()
directory = “C:\\irc”
if not os.path.exists(directory):
os.makedirs(directory)
filem = open(os.path.join(directory,”filewp.txt”), ‘r’)
post.content = str(filem.read())
#open(‘/storage/emulated/0/org.qpython.qpy/scripts/wordpress.py’).read().replace(‘*********’,’*********’)
post.id = wp.call(posts.NewPost(post))
post.post_status = ‘publish’
wp.call(posts.EditPost(post.id, post))

#pip install first http://python-wordpress-xmlrpc.readthedocs.io/en/latest/overview.html
#python3.4 windows
#from sn116229.wordpress.com

Advertisements