本文整理汇总了Python中wordpress_xmlrpc.WordPressPost类的典型用法代码示例。如果您正苦于以下问题:Python WordPressPost类的具体用法?Python WordPressPost怎么用?Python WordPressPost使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WordPressPost类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: build_collection_message
def build_collection_message(collection):
post = WordPressPost()
post.title = collection.title
games = []
for game in collection.games.all():
games.append({
'name' : game.name,
'brief_comment' : game.brief_comment,
'icon' : settings.MEDIA_URL + game.icon.name,
'category' : game.category.name,
'size' : game.size,
'platforms' : _get_game_platforms(game),
'id' : game.id,
'android_download_url' : game.android_download_url,
'iOS_download_url' : game.iOS_download_url,
'rating' : game.rating,
'recommended_reason' : _normalize_content(game.recommended_reason)
})
post.content = str(render_to_string('collection_web.tpl', {
'content' : _normalize_content(collection.recommended_reason),
'cover' : settings.MEDIA_URL + collection.cover.name,
'games' : games
}))
post.terms_names = {
'category' : [u'游戏合集']
}
post.post_status = 'publish'
return WebMessage(collection.id, post)
开发者ID:talentsun,项目名称:bestgames,代码行数:33,代码来源:web_message_builder.py
示例2: post
def post(self):
from lxml import etree
try:
self.ui.label.setText("Importing necessary modules...")
from wordpress_xmlrpc import Client, WordPressPost
status = 1
except:
status = 0
if(status==1):
from wordpress_xmlrpc.methods.posts import GetPosts, NewPost
from wordpress_xmlrpc.methods.users import GetUserInfo
self.ui.label.setText("Imported modules...")
data = etree.parse("config.xml")
user = data.find("user").text
url = data.find("url").text
pwd = data.find("pass").text
self.ui.label.setText("Imported data...")
try:
wp = Client(url+"/xmlrpc.php", user, pwd)
except:
status = 0
if (status == 1):
post = WordPressPost()
post.content = str(self.ui.BodyEdit.toPlainText())
post.title = str(self.ui.TitleEdit.text())
post.content = post.content + "<br><small><i>via QuickPress</i></small></br>"
post.post_status = 'publish'
wp.call(NewPost(post))
self.ui.label.setText("Published")
else:
self.ui.label.setText("Check Internet Connection and try again...")
else:
self.ui.label.setText("module(wordpress_xmlrpc) not found, you can install manually from terminal using pip install python-wordpress-xmlrpc")
开发者ID:joelewis,项目名称:QuickPress,代码行数:34,代码来源:launch.py
示例3: post_to_wordpress
def post_to_wordpress(self, story):
# Get number of posts to number the story title, i.e. if this is the 6th story
# that will get posted the title will be "Story 6"
print "Retrieving posts"
# get pages in batches of 20
num_of_post = 0
offset = 0
increment = 20
while True:
posts_from_current_batch = self.wp.call(posts.GetPosts({'number': increment, 'offset': offset}))
if len(posts_from_current_batch) == 0:
break # no more posts returned
else:
num_of_post += len(posts_from_current_batch)
offset = offset + increment
print num_of_post
# Create new post
print "Creating new post..."
post = WordPressPost()
post.title = 'Story %d' % (num_of_post + 1) # incrementing the number of post by 1
# convert each sentence to string, and join separated by a space.
post.content = " ".join(map(str, story))
post.id = self.wp.call(posts.NewPost(post))
# publish it
print "Publishing"
post.post_status = 'publish'
self.wp.call(posts.EditPost(post.id, post))
print "Done!"
开发者ID:Kmystic,项目名称:Turkey-Stories,代码行数:31,代码来源:mturk_wordpress.py
示例4: create_post
def create_post(title, text="", url="", image_url=""):
shortened_url = shorten_link(url) if url else ""
url_html = "<a href='{shortened_url}'>{url}</a><br/>".format(url=url, shortened_url=shortened_url) if url else ""
image_html = "<img style='width: 100%; height: auto;' src='{image_url}'></img><br/>".format(image_url=image_url) if image_url else ""
text_html = "<p>" + text + "</p>" + "<br/>" if text else ""
content = url_html + image_html + text_html
# https://developer.wordpress.com/docs/api/1.1/post/sites/%24site/posts/new/
# http://python-wordpress-xmlrpc.readthedocs.org/en/latest/examples/posts.html
post = WordPressPost()
post.title = title
post.content = content
post.author = "testaccount"
post.post_status = "publish"
# post.terms_names = {
# 'post_tag': ['test', 'firstpost'],
# 'category': ['Introductions', 'Tests']
# }
try:
redditsync.wordpress.wp.call(NewPost(post))
except Exception as err:
logging.error(str(err))
sys.exit()
开发者ID:AlJohri,项目名称:RedditSync,代码行数:27,代码来源:create_post.py
示例5: Publish_Post
def Publish_Post(title,body):
# Connect to Word Press POST API
obj=setup('https://hackingjournalismtest.wordpress.com/xmlrpc.php', 'contentmagicalsystem','aA9&cG^%[email protected]&h')
post = WordPressPost()
if len(title) == 0 :
raise("Cant Process the request")
return "Empty title requested"
if len(body) == 0:
rasie("Cant Process the request")
return "Empty body requested"
'''
Future or Next in line
Better data validations
Have some other quality checks for non ascii charecters and valdiate unicode letters if required
Request type validation (old vs new)
check if title already exist and update postif required
'''
post.title=title
post.content=body
# Make post visible ,status should be publish
post.post_status = 'publish'
# API call to push it to word press
post.id=wp.call(NewPost(post))
#return "Post created with id ",post.id
return post.id
开发者ID:macmania,项目名称:contentmagicalsystem,代码行数:29,代码来源:PublishPost.py
示例6: createPost
def createPost(image):
localFilename = 'images/{0}'.format(image + '.jpg')
print 'image is: {0}'.format(localFilename)
imageTimestamp = getTimestamp(image)
wpFilename = image + imageTimestamp + '.jpg'
data = {
'name': '{0}'.format(wpFilename),
'type': 'image/jpeg',
}
with open(localFilename, 'rb') as img:
data['bits'] = xmlrpc_client.Binary(img.read())
response = client.call(media.UploadFile(data))
print 'response is: {0}'.format(response)
month = strftime("%m", gmtime())
post = WordPressPost()
post.title = country + city
post.content = '[caption id="" align="alignnone" width ="640"]<img src="http://www.backdoored.io/wp-content/uploads/2016/' + month + '/' + wpFilename.replace(":", "") + '">' + ipAddress + hostnames + isp + timestamp + country + city + '[/caption]'
post.id = client.call(NewPost(post))
post.post_status = 'publish'
client.call(EditPost(post.id, post))
开发者ID:Ntlzyjstdntcare,项目名称:notShodan,代码行数:28,代码来源:notShodan.py
示例7: create_post_from_file
def create_post_from_file(a_file):
post = WordPressPost()
file_content = get_content_for_file(a_file)
match = yaml_match_from_post_data(file_content)
yaml_data = extract_yaml_data_using_match(file_content, match)
add_meta_info_from_yaml_to_post(yaml_data, post, a_file)
post.content = file_content[match.end():].strip()
return post
开发者ID:cabinw,项目名称:octo-2-wp,代码行数:8,代码来源:octoexport.py
示例8: make_post
def make_post(content, wp):
start = datetime.datetime.utcnow()
end = start + datetime.timedelta(7)
dates = (start.strftime('%b %d'), end.strftime('%b %d'))
post = WordPressPost()
post.title = "This week's schedule (%s - %s)" % dates
post.content = content
post.post_status = 'draft'
wp.call(NewPost(post))
开发者ID:splatspace,项目名称:mwp,代码行数:9,代码来源:post.py
示例9: build
def build(self, title, content, categories=[], tags=[]):
post = WordPressPost()
post.title = title
post.content = content
post.terms_names = {
'post_tag': tags,
'category': categories,
}
post.post_status = 'publish'
return NewPost(post)
开发者ID:smacpher,项目名称:HellaSlapsTheme,代码行数:10,代码来源:test.py
示例10: newPost
def newPost(title, content, tags, cats):
post = WordPressPost()
post.title = title
post.content = content
#post.post_status = 'publish'
post.terms_names = {
'post_tag': tags,
'category': cats
}
wp.call(NewPost(post))
开发者ID:tonycapone,项目名称:whatsfresh,代码行数:10,代码来源:wpPost.py
示例11: post_file
def post_file(wp, f, t, y, m, d):
p = WordPressPost()
p.title = t
p.content = slurp(f)
# 9am zulu is early Eastern-Pacific
p.date = p.date_modified = datetime(y,m,d,9)
p.post_status = 'publish'
p.comment_status = 'closed'
if wp:
wp.call(NewPost(p))
开发者ID:RubeRad,项目名称:dailycc,代码行数:10,代码来源:post_next_month.py
示例12: toWordPressPost
def toWordPressPost(self):
post = WordPressPost()
if self.title:
post.title = self.title
if self.content:
post.content = self.content
post.post_status = 'publish'
return post
开发者ID:CloCkWeRX,项目名称:googleplus2wordpress,代码行数:11,代码来源:plus.py
示例13: createPost
def createPost(self, post_title, post_content):
# create draft
post = WordPressPost()
post.title = post_title
post.content = post_content
post.id = self.wordpress.call(posts.NewPost(post))
# set status to be update
#post.post_status = 'publish'
#self.wordpress.call(posts.EditPost(post.id, post))
return post
开发者ID:RogerJieLuo,项目名称:Jasper-Customization,代码行数:11,代码来源:wordpresspost.py
示例14: postDraft
def postDraft(self, title, body):
'''
Creates a draft with title and graph
Currently both title and graph are just strings
'''
post = WordPressPost()
post.title = title
post.content = body
# post,terms_names = {
# 'post_tag': ['test'],
# 'category': ['testCat']}
self.wp.call(NewPost(post))
开发者ID:dagrha,项目名称:textual-analysis,代码行数:13,代码来源:blogpost.py
示例15: _make_post
def _make_post(client, title, content):
"""
Make a post on the wordpress site for this content item.
"""
print 'MAKING POST FOR:', title
post = WordPressPost()
post.title = title
post.content = content
post.terms_names = {
'post_tag': ['test', 'firstpost'],
'category': ['Introductions', 'Tests']
}
post.publish = True
client.call(NewPost(post))
开发者ID:psbanka,项目名称:yamzam,代码行数:14,代码来源:parse_cc.py
示例16: wp_post
def wp_post(post_title,post_content,post_tag):
wp = Client(wprpcurl, username, password)
print wp.call(GetPosts())
print wp.call(GetUserInfo())
post = WordPressPost()
post.title = post_title
post.content = post_content
dict1 = {}
for x in post_tag:
dict1.setdefault('post_tag',[]).append(str(x))
dict1.setdefault('category',[]).append('vps')
post.terms_names = dict1
post.post_status = 'publish'
wp.call(NewPost(post))
print wp.call(GetPosts())
开发者ID:rffanlab,项目名称:zrblog_spider,代码行数:15,代码来源:main.py
示例17: sourcename
def sourcename(url, cat1=None, cat2=None, cat3=None, d=True):
html = getPage(url, "page1.html")
os.remove('pages/page1.html')
title = html.select('h1')[0].text
first_para = html.select('.story-content > p:nth-of-type(1)')[0].text
second_para = html.select('.story-content > p:nth-of-type(2)')[0].text
try:
image = html.select('.image > img')[0].get('src')
except Exception:
image = None
wp = Client('http://www.domain.com/xml-rpc.php', 'username', 'password')
if image:
filename = 'http://www.livemint.com' + image
path = os.getcwd() + "\\00000001.jpg"
f = open(path, 'wb')
f.write(urllib.urlopen(filename).read())
f.close()
# prepare metadata
data = {
'name': 'picture.jpeg',
'type': 'image/jpeg', # mimetype
}
with open(path, 'rb') as img:
data['bits'] = xmlrpc_client.Binary(img.read())
response = wp.call(media.UploadFile(data))
post = WordPressPost()
post.title = title
post.user = 14
post.post_type = "post"
post.content = first_para + '\n' + '\n' + second_para
if d:
post.post_status = "draft"
else:
post.post_status = "publish"
if image:
attachment_id = response['id']
post.thumbnail = attachment_id
post.custom_fields = []
post.custom_fields.append({
'key': 'custom_source_url',
'value': url
})
if cat1:
cat1 = wp.call(taxonomies.GetTerm('category', cat1))
post.terms.append(cat1)
if cat2:
cat2 = wp.call(taxonomies.GetTerm('category', cat2))
post.terms.append(cat2)
if cat3:
cat3 = wp.call(taxonomies.GetTerm('category', cat3))
post.terms.append(cat3)
addpost = wp.call(posts.NewPost(post))
开发者ID:trujunzhang,项目名称:djzhang-targets,代码行数:53,代码来源:sample_code.py
示例18: blog_content
def blog_content(title,content,tage,category):
passwd=""
wp = Client('http://123.206.66.55/xmlrpc.php', 'admin', passwd)
"""
发表博文
"""
post = WordPressPost()
post.title = title
post.content = content
post.post_status = 'publish'
print tage
post.terms_names = {
'post_tag': tage,
'category': category
}
wp.call(NewPost(post))
开发者ID:Muxxs,项目名称:mylover,代码行数:16,代码来源:blog.py
示例19: post_picture
def post_picture(image_url):
fileImg = urlopen(image_url)
imageName = fileImg.url.split('/')[-1]+'.jpg'
data = {
'name': imageName,
'type': 'image/jpeg',
}
data['bits'] = xmlrpc_client.Binary(fileImg.read())
response = client.call(media.UploadFile(data))
attachment_id = response['id']
post = WordPressPost()
post.title = 'Picture of the Day'
post.post_status = 'publish'
post.thumbnail = attachment_id
post.id = client.call(posts.NewPost(post))
开发者ID:githubsec,项目名称:autopost,代码行数:16,代码来源:onePicture.py
示例20: posting
def posting():
wp = Client('<YOURWORDPRESSSIT>/xmlrpc.php','YOURUSERNAME','YOURPASSWORD')
#publish_date = (publish, '%a %b %d %H:%M:%S %Y %z')
post = WordPressPost()
post.title = title #Commit Title
post.content = description #Commit message
post.post_status = 'publish'
post.terms_names = {
'category': ['12SDD']
}
#post.date = publish_date
#Creates a new wordpress post and posts it on the site.
wp.call(NewPost(post))
开发者ID:ryan-mccartney,项目名称:AWBL,代码行数:16,代码来源:autoPostWordpress.py
注:本文中的wordpress_xmlrpc.WordPressPost类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论