account_association_task.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. """
  2. @author: luojunhui
  3. 账号联想---账号搜索任务
  4. """
  5. import traceback
  6. from argparse import ArgumentParser
  7. from datetime import datetime
  8. from applications import bot
  9. from coldStartTasks.crawler.weixin_account_association_crawler import AccountAssociationCrawler
  10. def main():
  11. """
  12. 账号联想---账号搜索任务
  13. :return:
  14. """
  15. parser = ArgumentParser()
  16. parser.add_argument("--run-date",
  17. help="Run only once for date in format of %Y-%m-%d. \
  18. If no specified, run as daily jobs.")
  19. args = parser.parse_args()
  20. if args.run_date:
  21. biz_date_str = args.run_date
  22. else:
  23. biz_date_str = datetime.today().strftime('%Y-%m-%d')
  24. try:
  25. biz_date = datetime.strptime(biz_date_str, "%Y-%m-%d")
  26. account_association_crawler = AccountAssociationCrawler()
  27. account_association_crawler.run_account_association(biz_date=biz_date)
  28. except Exception as e:
  29. bot(
  30. title="账号联想任务失败",
  31. detail={
  32. "error": str(e),
  33. "error_stack": traceback.format_exc()
  34. }
  35. )
  36. if __name__ == '__main__':
  37. main()