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


Python WordPressPost.id方法代码示例

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


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

示例1: post_article

# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import id [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

示例2: post_to_wordpress

# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import id [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

示例3: Publish_Post

# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import id [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

示例4: createPost

# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import id [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

示例5: doPost

# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import id [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

示例6: postInWordpress

# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import id [as 别名]
 def postInWordpress(self, title, content, ):
     post = WordPressPost()
     post.title = title
     post.content = content
     post.post_status = 'publish'
     post.terms_names = {'post_tag': ['leak', 'pastebin leak', 'hack leak', 'hack'],'category': ['Leaks']}
     post.id = self.wordpress.call(NewPost(post))
     p = self.wordpress.call(GetPosts())[0]
     return p.link
开发者ID:AlejandroMoran,项目名称:LeaksCrawler,代码行数:11,代码来源:Crawler.py

示例7: build_draft_post

# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import id [as 别名]
def build_draft_post(title, content):
    post = WordPressPost()
    post.title = title
    post.content = content
    post.terms_names = {
        'post_tag': config_keys['wordpress_tags'],
        'category': config_keys['wordpress_categories']
    }

    # Don't duplicate same year / week no; reuse
    current_posts = wp.call(posts.GetPosts())
    dup_posts = filter(lambda p: p.title.split(':') == post.title.split(':'), current_posts)
    if dup_posts:
        # lets assume this returns in a sensible order
        dup_id = dup_posts[0].id
        wp.call(posts.EditPost(dup_id, post))
        post.id = dup_id
    else:
        post.id = wp.call(posts.NewPost(post))
    return post
开发者ID:andrewbolster,项目名称:pyweeknote-generator,代码行数:22,代码来源:post_to_wordpress.py

示例8: createPost

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

示例9: create_wordpress_draft

# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import id [as 别名]
def create_wordpress_draft(publish_target, title, html, tags):
  post = WordPressPost()
  today = datetime.date.today()
  post.title = title
  post.content = html
  client = Client( publish_target["url"] + "/xmlrpc.php",  publish_target["username"],  publish_target["password"])
  category = client.call(taxonomies.GetTerm('category',  publish_target["default_category_id"]))
  post.terms.append(category)
  post.user = publish_target["default_user_id"]
  post.terms_names = {'post_tag': tags}
  post.comment_status = 'open'
  post.id = client.call(posts.NewPost(post))
  return post
开发者ID:Arsenalist,项目名称:Quick-Reaction,代码行数:15,代码来源:app.py

示例10: func_Create_WP_Post

# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import id [as 别名]
def func_Create_WP_Post(atitle, acontent, category):
	wp = Client(WPPATH, WPUSER, WPPASS)
	my_category = category
	post = WordPressPost()
	post.title = atitle
	post.content = acontent
	post.post_format = "video"
	post.terms_names = {'category':[my_category]}

	
	print(category)
	print("---")
	
	my_posts = []
	#my_posts = set()
	my_increment = 20
	my_offset = 0
	while True:
		wp_obj_posts = wp.call(posts.GetPosts({'number': my_increment, "offset": my_offset}))
		if len(wp_obj_posts) == 0:
			break
		for apost in wp_obj_posts:
			apost = apost.content
			apost = apost.split("embed/",1)[1]
			#my_posts.add(apost) 
			my_posts.append(apost) 
			#try:
			#	print(apost.title)
			#except UnicodeEncodeError:
			#	print("'ascii' codec can't encode character.")
		my_offset += my_increment

	#print(wp_obj_posts)
	#print("---")
	
	print(my_posts)
	print("---")

	post_id = post.content.split("embed/",1)[1]
	print(post_id)
	#my_posts = sorted(my_posts)
	if post_id in my_posts:
		print("Dublicate post!!!\n")
		print("---")
	else:
		print("Posted!\n")
		print("---")
		post.id = wp.call(posts.NewPost(post))
		post.post_status = 'publish'
		wp.call(posts.EditPost(post.id, post))
开发者ID:SergeyBondarenko,项目名称:vicubic,代码行数:52,代码来源:wpPostman.py

示例11: process_item

# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import id [as 别名]
 def process_item(self, item, spider):
     post = WordPressPost()
     post.title = item['title']
     post.content = item['content'] + settings.get('GOTO_SOURCE', "[%s]") % item['link']
     post.date = datetime.datetime.strptime(item['publish_date'],
                                         "%Y-%m-%d %H:%M")
     post.terms_names = {
         'post_tag': item['tag'],
         'category': item['category'] if len(item['category']) > 0 else ['gist'],
     }
     post.post_status = 'publish'
     post.thumbnail = self.create_thumbnail(item)
     post.id = self.client.call(posts.NewPost(post))
     return item
开发者ID:zhanghui9700,项目名称:spider.appcheckin.com,代码行数:16,代码来源:pipelines.py

示例12: wordPressPost

# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import id [as 别名]
def wordPressPost():
	for i in range(38):
		content = """<iframe src="//www.youtube-nocookie.com/embed/""" + urls[i] + """?rel=0" \
height="360" width="640" allowfullscreen="" frameborder="0"></iframe>"""

		post = WordPressPost()
		post.title = titles[i]
		post.content = content
		print titles[i]
		print content
		post.link = 'http://medtwice.com/pregnancy-by-week-week-'+str(i+4)
		post.post_status = 'publish'
		category = wp.call(taxonomies.GetTerm('category', 44))
		post.terms.append(category)
		post.id = wp.call(NewPost(post))
开发者ID:jagtodeath,项目名称:medTwicePoster,代码行数:17,代码来源:youtube.py

示例13: addItem

# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import id [as 别名]
    def addItem(self, item):
        # 跳转链作为唯一标识去重
#        exist_posts = self.rpcClient.call(posts.GetPosts({'custom_fields':{'key':'link_value', 'value' : item.link}}))
        if self.itemExist(item.link):
            return
        print 'item.link = '+item.link
        res = urlparse.urlparse(item.thumb)
        if len(res.query) > 0:
            qs = urlparse.parse_qs(res.query)
#    huihui图片ID
            des = qs['id'][0]
            filename = des+'.png'
            destfile = 'temp/'+filename
        else:
            filename = item.thumb[item.thumb.rfind('/'):]
            destfile = 'temp'+filename
        downloadimage(item.thumb,destfile)
        
        # prepare metadata
        data = {
                'name': filename,
                'type': 'image/png',  # mimetype
        }
        
        # read the binary file and let the XMLRPC library encode it into base64
        with open(destfile, 'rb') as img:
                data['bits'] = xmlrpc_client.Binary(img.read())
        
        response = self.rpcClient.call(media.UploadFile(data))
        attachment_id = response['id']

        post = WordPressPost()
        post.title = item.title
        post.content = item.content
        post.thumbnail = attachment_id
        post.custom_fields = [{'key':'link_value', 'value' : item.link}]
        post.id = self.rpcClient.call(posts.NewPost(post))
    #    # attachment_id.parentid = post.id
    #    # whoops, I forgot to publish it!
        post.post_status = 'publish'
        
#        cats = self.rpcClient.call(taxonomies.GetTerms('category'))
        for cat in self.categorys:
            if cat.name == item.category:
                post.terms = [cat]
                break
                
        self.rpcClient.call(posts.EditPost(post.id, post))
开发者ID:sunyifei83,项目名称:python-py,代码行数:50,代码来源:test_wanbin.py

示例14: upload

# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import id [as 别名]
def upload(name, title):
    client = Client("http://domain.com/xmlrpc.php", "username", "password")
    imgfile = os.path.join(DATA_DIR, name)
    # imgfile = 'op/%s'%name
    data = {"name": name, "type": "image/jpg"}
    with open(imgfile, "rb+") as imag:
        data["bits"] = xmlrpc_client.Binary(imag.read())
    response = client.call(media.UploadFile(data))
    attachment_id = response["id"]
    _title = lxml.html.fromstring(title).text
    post = WordPressPost()
    post.title = _title
    post.post_status = "publish"
    post.thumbnail = attachment_id
    post.comment_status = "open"
    post.id = client.call(posts.NewPost(post))
开发者ID:heaven00,项目名称:python-script-Scraper,代码行数:18,代码来源:9gag_scraper.py

示例15: publish

# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import id [as 别名]
def publish(pic, title, content):
    '''
    '''
    attachment = upload(pic)
    wp_client = Client(rpc_service_url, user, password)
    post = WordPressPost()
    post.title = title
    post.content = '%s\n\n<a href="%s"><img class="alignnone size-full wp-image-%s" alt="%s" src="%s" /></a>' % (content, attachment["url"], attachment["id"], attachment["file"], attachment["url"])
    #post.tags='test, test2'
    #post.categories=['pet','picture']
    post.thumbnail = attachment["id"]
    #change status to publish
    post.id = wp_client.call(posts.NewPost(post))
    post.post_status = 'publish'
    wp_client.call(posts.EditPost(post.id, post))
    return post.id
开发者ID:ccfruit,项目名称:52woo,代码行数:18,代码来源:autopublish.py


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