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


Python Post.title方法代码示例

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


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

示例1: post

# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import title [as 别名]
    def post(self):
        user = users.get_current_user()
        if not user or not users.is_current_user_admin():
            self.redirect(users.create_login_url(self.request.uri))
            return

        post = Post()
        post.title = self.request.POST['title']
        post.put()

        self.redirect('/admin/posts/edit/' + str(post.key.id()))
开发者ID:eholec,项目名称:jetpoweredblog,代码行数:13,代码来源:posts.py

示例2: post_link

# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import title [as 别名]
def post_link(environ,start_response):
   try:
      request_body_size = int(environ.get('CONTENT_LENGTH', 0))
   except (ValueError):
      request_body_size = 0
   request_body = environ['wsgi.input'].read(request_body_size)
   d = parse_qs(request_body)
   print d,request_body_size
   url = escape(d.get('url', ['http://www.google.com'])[0])
   title = escape(d.get('title', ['No title.'])[0])

   from daemon import post_queue
   from post import Post
   mypost=Post()
   mypost.url=url
   mypost.title=title
   post_queue.put(mypost)

   response_body=post_link_html % url
   response_headers = [('Content-Type', 'text/html;charset=utf-8'),
                  ('Content-Length', str(len(response_body)))]
   start_response('200 OK', response_headers)
   return [response_body]
开发者ID:imclab,项目名称:decentralized,代码行数:25,代码来源:submit.py

示例3: parse_all_posts

# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import title [as 别名]
    def parse_all_posts(self, author=True, title=True, date=True, contents=True, messages=True,
                        reply=True, images=True, ip=False):
        try:
            if self.post_urls is None:
                raise Exception("You must run get_posts_url first")
        except Exception as err:
            print(err)
            sys.exit(1)

        post_objects = list()
        for url in self.post_urls:
            post_url = "http://www.ptt.cc/bbs/{}/{}".format(self.board_name, url)
            soup = self._get_soup(post_url)
            post = Post(post_url)

            try:
                article_meta = soup.find_all('span', class_="article-meta-value")
                if author:
                    post.author = article_meta[0].contents[0]

                if title:
                    post.title = article_meta[2].contents[0]

                if date:
                    post.date = article_meta[3].contents[0]

                # TODO: ip
                if ip:
                    pass

                if contents:
                    a = str(soup.find(id="main-container").contents[1])
                    a = a.split("</div>")
                    a = a[4].split("<span class=\"f2\">※ 發信站: 批踢踢實業坊(ptt.cc),")
                    post.contents = a[0].replace(' ', '').replace('\n', '').replace('\t', '')

                if images:
                    a = soup.find_all('img')
                    imgs = list()
                    for i in a:
                        imgs.append(i.attrs.get('src'))
                    post.images = imgs

                # TODO: There are some push_content lost due to hyperlink in the content
                if messages or reply:
                    # messages = list()
                    for tag in soup.find_all("div", "push"):
                        # d = dict()
                        push_tag = tag.find("span", "push-tag").\
                            string.replace(' ', '')

                        # d.setdefault('狀態', push_tag)
                        # d.setdefault('留言者', push_userid)
                        # d.setdefault('留言內容', push_content)
                        # d.setdefault('留言時間', push_ipdatetime)

                        # messages.append(d)

                        if push_tag == '推':
                            post.good += 1
                        elif push_tag == '噓':
                            post.bad += 1
                        else:
                            post.normal += 1

                    # post.messages = messages
            except:
                pass

            post_objects.append(post)

        return post_objects
开发者ID:ricky155030,项目名称:ptt-crawler,代码行数:74,代码来源:pttcrawler.py


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