task5.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. """
  2. @author: luojunhui
  3. """
  4. import time
  5. from applications import PQMySQL
  6. class AccountArticleProducer(object):
  7. """
  8. step1: 获取已有账号历史表现好的文章list
  9. step2: 每篇文章搜索一个文章list,获取最好的文章所对应的账号信息
  10. step3: 对于该账号的历史文章进行抓取,把数据更新的文章库
  11. step4: 根据该账号历史文章的表现,返回该账号的优质文章
  12. """
  13. pq_mysql = PQMySQL()
  14. @classmethod
  15. def getHistoryArticles(cls, gh_id, latest_time_stamp):
  16. """
  17. 获取账号的历史文章
  18. :param latest_time_stamp:
  19. :param gh_id:
  20. :return:
  21. """
  22. twenty_hours_ago = int(time.time()) - 3600 * 20
  23. sql = f"""
  24. select title, show_view_count from official_articles
  25. where ghId = '{gh_id}' and updateTime > {latest_time_stamp} and updateTime < {twenty_hours_ago};
  26. """
  27. history_article_list = cls.pq_mysql.select(sql)
  28. return history_article_list
  29. @classmethod
  30. def findGoodArticles(cls, gh_id):
  31. """
  32. :param gh_id:
  33. :return:
  34. """
  35. return
  36. @classmethod
  37. def updateArticlesToMysql(cls):
  38. """
  39. :return:
  40. """