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


Python WordPressPost.user方法代码示例

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


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

示例1: sourcename

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

示例2: create_wordpress_draft

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

示例3: publish

# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import user [as 别名]
def publish(pic, title, content):
    '''
    publish a post and set to open to comment and ping(trackback)
    '''
    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'
    post.comment_status = 'open'
    post.ping_status = 'open'
    post.user = account_ids[r.randint(0, len(account_ids)-1)]
    wp_client.call(posts.EditPost(post.id, post))
    return post.id
开发者ID:ZHTonyZhang,项目名称:52woo,代码行数:22,代码来源:publish.py

示例4: entry_to_wppost

# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import user [as 别名]
def entry_to_wppost(entry, client):
    post             = WordPressPost()
    # Convert entry values to Post value
    post.user        = get_author_by_display_name(entry.author, client)
    post.date        = entry.published_parsed
    post.post_status = "draft"
    post.title       = entry.title
    post.content     = entry.content[0].value
    post.excerpt     = entry.summary
    post.link        = entry.link
    # There is some given tags
    if len(entry.tags):
        entry.tags = [t.term for t in entry.tags]
        # Add category (with the first tag)
        post.terms_names = {
            'category': entry.tags[0:1],
            'post_tag': [],
        }
        # Add tags
        if len(entry.tags) > 1: post.terms_names['post_tag'] = entry.tags[1:]
    return post
开发者ID:Web5design,项目名称:rss2wp,代码行数:23,代码来源:parser.py


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