run_video_account_crawler.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. """
  2. @author: luojunhui
  3. 执行视频&&账号的抓取
  4. """
  5. import traceback
  6. from applications import bot
  7. from coldStartTasks.crawler import WeixinAccountCrawler, WeixinVideoCrawler
  8. account_crawler = WeixinAccountCrawler()
  9. video_crawler = WeixinVideoCrawler()
  10. def main():
  11. """
  12. 主函数
  13. :return:
  14. """
  15. # 先执行账号抓取
  16. try:
  17. account_crawler.run()
  18. except Exception as e:
  19. error_msg = traceback.format_exc()
  20. bot(
  21. title='账号抓取v1执行失败',
  22. detail={
  23. "error": str(e),
  24. "traceback": error_msg
  25. }
  26. )
  27. # 再执行文章抓取
  28. try:
  29. video_crawler.run()
  30. except Exception as e:
  31. error_msg = traceback.format_exc()
  32. bot(
  33. title='视频抓取执行失败',
  34. detail={
  35. "error": str(e),
  36. "traceback": error_msg
  37. }
  38. )
  39. # 再执行账号抓取v2
  40. try:
  41. account_crawler.run_v2()
  42. except Exception as e:
  43. error_msg = traceback.format_exc()
  44. bot(
  45. title='账号抓取V2执行失败',
  46. detail={
  47. "error": str(e),
  48. "traceback": error_msg
  49. }
  50. )
  51. if __name__ == '__main__':
  52. main()