当前位置: 首页>>代码示例>>Python>>正文


Python WordPressPost.content方法代码示例

本文整理汇总了Python中wordpress_xmlrpc.WordPressPost.content方法的典型用法代码示例。如果您正苦于以下问题:Python WordPressPost.content方法的具体用法?Python WordPressPost.content怎么用?Python WordPressPost.content使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在wordpress_xmlrpc.WordPressPost的用法示例。


在下文中一共展示了WordPressPost.content方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post

# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import content [as 别名]
	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,代码行数:36,代码来源:launch.py

示例2: post_article

# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import content [as 别名]
    def post_article(self, wordpress_link, wordpress_id, wordpress_pass, articletitle, articlecategories,
                     articlecontent, articletags, imagelink=None):
        if imagelink:
            self.path = os.getcwd() + "\\00000001.jpg"
            self.articlePhotoUrl = imagelink
            self.wpUrl = wordpress_link
            self.wpUserName = wordpress_id
            self.wpPassword = wordpress_pass
            # Download File
            f = open(self.path, 'wb')
            f.write(urllib.urlopen(self.articlePhotoUrl).read())
            f.close()
            # Upload to WordPress
            client = Client(self.wpUrl, self.wpUserName, self.wpPassword)
            filename = self.path
            # prepare metadata
            data = {
                'name': 'picture.jpg', 'type': 'image/jpg',
            }

            # read the binary file and let the XMLRPC library encode it into base64
            with open(filename, 'rb') as img:
                data['bits'] = xmlrpc_client.Binary(img.read())
            response = client.call(media.UploadFile(data))
            attachment_id = response['id']
            # Post
            post = WordPressPost()
            post.title = articletitle
            post.content = articlecontent
            post.terms_names = {'post_tag': articletags, 'category': articlecategories}
            post.post_status = 'publish'
            post.thumbnail = attachment_id
            post.id = client.call(posts.NewPost(post))
            print 'Post Successfully posted. Its Id is: ', post.id
        else:
            self.wpUrl = wordpress_link
            self.wpUserName = wordpress_id
            self.wpPassword = wordpress_pass
            # Upload to WordPress
            client = Client(self.wpUrl, self.wpUserName, self.wpPassword)
            # Post
            post = WordPressPost()
            post.title = articletitle
            post.content = articlecontent
            post.terms_names = {'post_tag': articletags, 'category': articlecategories}
            post.post_status = 'publish'
            post.id = client.call(posts.NewPost(post))
            print 'Post Successfully posted. Its Id is: ', post.id
开发者ID:KamiworksCat,项目名称:XMLRPC-wordpress-upload,代码行数:50,代码来源:wordpress_upload.py

示例3: create_post

# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import content [as 别名]
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,代码行数:29,代码来源:create_post.py

示例4: Publish_Post

# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import content [as 别名]
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,代码行数:31,代码来源:PublishPost.py

示例5: postToWordpress

# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import content [as 别名]
def postToWordpress(text, thisDay, wp):
    """Publishes the blog post to WordPress.
    
    Arguments:
    text -- HTML text body of the post.
    thisDay -- The date of the post, which will also become the title.
    
    Return:
    post.title -- The title of the WordPress post.
    True / False -- Whether or not the post was successfully posted.
    
    """
    post = WordPressPost()
    post.title = dateToString(thisDay)
    post.content = text
    post.date = (thisDay + 
                datetime.timedelta(0,0,0,0,30,23)) # 6:30pm, EST
    post.post_status = 'publish'
    post.terms_names = {
                        'post_tag': ['Journal Entry', 'Food'],
                        'category': ['Journal']
                        }
    try:
        wp.call(NewPost(post))
    except:
        return (post.title,False)
    return (post.title, True)
开发者ID:schlosser,项目名称:FoodJournal,代码行数:29,代码来源:WordPressPostGenerator.py

示例6: doPost

# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import content [as 别名]
 def doPost(self):
     post = WordPressPost()
     
     # get all post properties
     post.title = str(unicode(self.lnEdit_PostTitle.text()))
     post.content = str(unicode(self.txtEdit_PostContent.toPlainText()))
     tag = unicode(self.lnEditPostTags.text())
     category = unicode(self.lnEditPostCategories.text())
     # use ',' split multi-tag or category
     if ',' in tag: tag = tag.split(',')
     if ',' in category: category = category.split(',')
     post.terms_names = {
         'post_tag': tag,
         'category': category
     }
     post.post_status = str(self.cb_post_status.currentText())
     
     try:
         # new post or page-type post
         if (self._newPost_):
             post.id = self.wp.call(posts.NewPost(post))
             QtGui.QMessageBox.information(self, 'info', "Post success!", QtGui.QMessageBox.Ok)
         else:
             print 'edit...'
             # edit a post
             if self._postId_ != None:
                 self.wp.call(posts.EditPost(self._postId_, post))
                 QtGui.QMessageBox.information(self, 'info', "Edit success!", QtGui.QMessageBox.Ok)
     except Exception, e:
         QtGui.QMessageBox.information(self, 'err', str(e), QtGui.QMessageBox.Ok)
开发者ID:ifconfigyeah,项目名称:cwppm,代码行数:32,代码来源:DlgPost.py

示例7: post_to_wordpress

# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import content [as 别名]
	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,代码行数:33,代码来源:mturk_wordpress.py

示例8: createPost

# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import content [as 别名]
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,代码行数:30,代码来源:notShodan.py

示例9: build_news_message

# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import content [as 别名]
def build_news_message(news):
	post = WordPressPost()
	post.title = news.brief_comment

	converted_video_url = None
	if news.video_url is not None:
		converted_video_url = convert_youku_video_url(news.video_url)

	content_items = {'content' : _normalize_content(news.recommended_reason)}
	if news.screenshot_path_1:
		content_items['screenshot_path_1'] = settings.MEDIA_URL + news.screenshot_path_1.name
	if news.screenshot_path_2:
		content_items['screenshot_path_2'] = settings.MEDIA_URL + news.screenshot_path_2.name
	if news.screenshot_path_3:
		content_items['screenshot_path_3'] = settings.MEDIA_URL + news.screenshot_path_3.name
	if news.screenshot_path_4:
		content_items['screenshot_path_4'] = settings.MEDIA_URL + news.screenshot_path_4.name
	content_items['video_url'] = converted_video_url
	post.content = str(render_to_string('news_web.tpl', content_items))

	post.terms_names = {
		'category' : [u'新游预告']
	}

	if news.screenshot_path_1.name != '':
		post.custom_fields = []
		post.custom_fields.append({'key':'post_image','value':settings.MEDIA_URL + news.screenshot_path_1.name})

	post.post_status = 'publish'

	return WebMessage(news.id, post)
开发者ID:talentsun,项目名称:bestgames,代码行数:33,代码来源:web_message_builder.py

示例10: build_game_message

# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import content [as 别名]
def build_game_message(game):
	post = WordPressPost()
	post.title = '%s - %s' % (game.name, game.brief_comment)

	converted_video_url = None
	if game.video_url is not None:
		converted_video_url = convert_youku_video_url(game.video_url)
	post.content = str(render_to_string('game_web.tpl', {
		'content' : _normalize_content(game.recommended_reason),
		'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,
		'screenshot_path_1' : settings.MEDIA_URL + game.screenshot_path_1.name,
		'screenshot_path_2' : settings.MEDIA_URL + game.screenshot_path_2.name,
		'screenshot_path_3' : settings.MEDIA_URL + game.screenshot_path_3.name,
		'screenshot_path_4' : settings.MEDIA_URL + game.screenshot_path_4.name,
		'video_url' : converted_video_url
	}))

	post.terms_names = {
		'category' : [game.category.name],
		'post_tag' : _get_game_tags(game)
	}

	if game.screenshot_path_1.name != '':
		post.custom_fields = []
		post.custom_fields.append({'key':'post_image','value':settings.MEDIA_URL + game.screenshot_path_1.name})

	post.post_status = 'publish'

	return WebMessage(game.id, post)
开发者ID:talentsun,项目名称:bestgames,代码行数:37,代码来源:web_message_builder.py

示例11: build_evaluation_message

# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import content [as 别名]
def build_evaluation_message(evaluation):
	post = WordPressPost()
	post.title = evaluation.title

	post.content = str(render_to_string('evaluation_web.tpl', {
		'id' : evaluation.id,
		'content' : _normalize_content(evaluation.recommended_reason),
		'icon' : settings.MEDIA_URL + evaluation.icon.name,
		'platforms' : _get_game_evaluation_platforms(evaluation),
		'android_download_url' : evaluation.android_download_url,
		'iOS_download_url' : evaluation.iOS_download_url,
		'evaluation_content' : evaluation.content,
		'rating' : evaluation.rating,
	}))

	post.terms_names = {
		'category' : [u'游戏测评'],
		'post_tag' : _get_game_evaluation_tags(evaluation)
	}
	if evaluation.icon.name != '':
		post.custom_fields = []
		post.custom_fields.append({'key':'post_image','value':settings.MEDIA_URL + evaluation.icon.name})

	post.post_status = 'publish'

	return WebMessage(evaluation.id, post)
开发者ID:talentsun,项目名称:bestgames,代码行数:28,代码来源:web_message_builder.py

示例12: build_collection_message

# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import content [as 别名]
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,代码行数:35,代码来源:web_message_builder.py

示例13: create_post_from_file

# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import content [as 别名]
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,代码行数:10,代码来源:octoexport.py

示例14: process_comment

# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import content [as 别名]
def process_comment(wp, video_id, parent_post_id, comment):
    post = WordPressPost()
    post.title = comment['text'][6:50]
    post.content = get_post_content(video_id,comment)
    post.post_type = 'video-highlight'
    post.post_status = 'publish'
    post.parent_id = parent_post_id
    #logger.info("Created post with ID [%s]", wp.call(NewPost(post)))
    print "Created post with ID [%s]" % wp.call(NewPost(post))
开发者ID:kalsop,项目名称:Vimeo-video-comments-to-Wordpress-post,代码行数:11,代码来源:vimeo_wp.py

示例15: testUpdate

# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import content [as 别名]
def testUpdate(pid):
    client = initClient()
    post = WordPressPost()
    post.title = 'My new title update 2'
    post.content = 'This is the body of my new post.'
    post.slug= 'helloword'
    post.post_type = 'post'
    post.post_status = 'draft'
    print client.call(posts.EditPost(pid, post))
开发者ID:tl3shi,项目名称:markdown2wordpress,代码行数:11,代码来源:md2wp.py


注:本文中的wordpress_xmlrpc.WordPressPost.content方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。