예제 #1
0
def list_posts(ctx,
               account=None,
               tag=None,
               keyword=None,
               limit=None,
               days=None,
               debug=False):
    """ list the post by account, tag, keyword, etc. """

    if debug:
        settings.set_debug_mode()
    settings.set_steem_node()

    get_posts(account, tag, keyword, limit, days)
예제 #2
0
 def _has_published(self, title):
     posts = get_posts(account=self.author, limit=50)
     if len(posts) > 0:
         for post in posts:
             if post.title == title:
                 return True
     return False
예제 #3
0
 def _read_posts(self):
     print("fetching posts...")
     if self.tags and len(self.tags) > 0:
         posts = []
         for t in self.tags:
             posts_t = get_posts(tag=t,
                                 account=self.account,
                                 keyword=self.keyword,
                                 limit=self.limit,
                                 days=self.days)
             posts = self._merge_posts(posts, posts_t, 'url')
         return posts
     else:
         return get_posts(tag=self.tag,
                          account=self.account,
                          keyword=self.keyword,
                          limit=self.limit,
                          days=self.days)
예제 #4
0
 def _has_published(self, title):
     try:
         posts = get_posts(account=self.author, limit=50)
         if len(posts) > 0:
             for post in posts:
                 if post.title == title:
                     return True
     except:
         logger.error("Failed when checking publish states. Error: {}".format(traceback.format_exc()))
         return False
     return False
예제 #5
0
 def _has_published(self, title, keyword):
     settings.set_steem_node(CURRENT_API_NODE,
                             overwrite=True,
                             condenser=True)
     posts = get_posts(account=self.author, keyword=keyword, limit=10)
     settings.set_steem_node(CURRENT_API_NODE,
                             overwrite=True,
                             condenser=False)
     if len(posts) > 0:
         for post in posts:
             if post.title == title:
                 return True
     return False
예제 #6
0
 def get_yesterday_posts(self):
     title = self.title(data=None, days=-2)  # fix the date string error
     posts = get_posts(account=RESTEEM_ACCOUNT, days=2)
     yesterday_summary_posts = [p for p in posts if p.title == title]
     if yesterday_summary_posts and len(yesterday_summary_posts) > 0:
         yesterday_summary_post = yesterday_summary_posts[0]
         try:
             html = markdown(yesterday_summary_post.body)
             soup = BeautifulSoup(html, 'lxml')
             tags = soup.select("tbody tr td a")
             return [t["href"] for t in tags]
         except:
             logger.info("Failed when parsing posts, with error: {}".format(
                 traceback.format_exc()))
     return []
예제 #7
0
 def crawl(self):
     return get_posts(account=self.account, days=self.days)