account_association_task.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 = datetime.strptime(args.run_date, "%Y-%m-%d")
  22. else:
  23. biz_date = datetime.today()
  24. try:
  25. account_association_crawler = AccountAssociationCrawler()
  26. account_association_crawler.run_account_association(biz_date=biz_date)
  27. except Exception as e:
  28. bot(
  29. title="账号联想任务失败",
  30. detail={
  31. "error": str(e),
  32. "error_stack": traceback.format_exc()
  33. }
  34. )
  35. if __name__ == '__main__':
  36. main()