updatePublishedMsgDaily.py 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729
  1. """
  2. @author: luojunhui
  3. @description: update daily information into official articles v2
  4. """
  5. import time
  6. import json
  7. import traceback
  8. import urllib.parse
  9. from tqdm import tqdm
  10. from datetime import datetime
  11. from argparse import ArgumentParser
  12. from applications import PQMySQL, WeixinSpider, Functions, log, bot, aiditApi, longArticlesMySQL
  13. from applications.const import updatePublishedMsgTaskConst
  14. ARTICLE_TABLE = "official_articles_v2"
  15. const = updatePublishedMsgTaskConst()
  16. spider = WeixinSpider()
  17. functions = Functions()
  18. def get_account_using_status():
  19. """
  20. 获取正在 using 的 ghid
  21. :return:
  22. """
  23. sql = "SELECT gh_id FROM long_articles_publishing_accounts WHERE is_using = 1;"
  24. gh_id_tuple = PQMySQL().select(sql)
  25. gh_id_list = [
  26. i[0] for i in gh_id_tuple
  27. ]
  28. return set(gh_id_list)
  29. def get_accounts():
  30. """
  31. 从 aigc 数据库中获取目前处于发布状态的账号
  32. :return:
  33. "name": line[0],
  34. "ghId": line[1],
  35. "follower_count": line[2],
  36. "account_init_time": int(line[3] / 1000),
  37. "account_type": line[4], # 订阅号 or 服务号
  38. "account_auth": line[5]
  39. """
  40. using_account_set = get_account_using_status()
  41. account_list_with_out_using_status = aiditApi.get_publish_account_from_aigc()
  42. account_list = []
  43. for item in account_list_with_out_using_status:
  44. if item['ghId'] in using_account_set:
  45. item['using_status'] = 1
  46. else:
  47. item['using_status'] = 0
  48. account_list.append(item)
  49. subscription_account = [i for i in account_list if i['account_type'] in const.SUBSCRIBE_TYPE_SET]
  50. server_account = [i for i in account_list if i['account_type'] == const.SERVICE_TYPE]
  51. return subscription_account, server_account
  52. def insert_each_msg(db_client, account_info, account_name, msg_list):
  53. """
  54. 把消息数据更新到数据库中
  55. :param account_info:
  56. :param db_client:
  57. :param account_name:
  58. :param msg_list:
  59. :return:
  60. """
  61. gh_id = account_info['ghId']
  62. for info in msg_list:
  63. baseInfo = info.get("BaseInfo", {})
  64. appMsgId = info.get("AppMsg", {}).get("BaseInfo", {}).get("AppMsgId", None)
  65. createTime = info.get("AppMsg", {}).get("BaseInfo", {}).get("CreateTime", None)
  66. updateTime = info.get("AppMsg", {}).get("BaseInfo", {}).get("UpdateTime", None)
  67. Type = info.get("AppMsg", {}).get("BaseInfo", {}).get("Type", None)
  68. detail_article_list = info.get("AppMsg", {}).get("DetailInfo", [])
  69. if detail_article_list:
  70. for article in detail_article_list:
  71. title = article.get("Title", None)
  72. Digest = article.get("Digest", None)
  73. ItemIndex = article.get("ItemIndex", None)
  74. ContentUrl = article.get("ContentUrl", None)
  75. SourceUrl = article.get("SourceUrl", None)
  76. CoverImgUrl = article.get("CoverImgUrl", None)
  77. CoverImgUrl_1_1 = article.get("CoverImgUrl_1_1", None)
  78. CoverImgUrl_235_1 = article.get("CoverImgUrl_235_1", None)
  79. ItemShowType = article.get("ItemShowType", None)
  80. IsOriginal = article.get("IsOriginal", None)
  81. ShowDesc = article.get("ShowDesc", None)
  82. show_stat = Functions().show_desc_to_sta(ShowDesc)
  83. ori_content = article.get("ori_content", None)
  84. show_view_count = show_stat.get("show_view_count", 0)
  85. show_like_count = show_stat.get("show_like_count", 0)
  86. show_zs_count = show_stat.get("show_zs_count", 0)
  87. show_pay_count = show_stat.get("show_pay_count", 0)
  88. wx_sn = ContentUrl.split("&sn=")[1].split("&")[0] if ContentUrl else None
  89. status = account_info['using_status']
  90. info_tuple = (
  91. gh_id,
  92. account_name,
  93. appMsgId,
  94. title,
  95. Type,
  96. createTime,
  97. updateTime,
  98. Digest,
  99. ItemIndex,
  100. ContentUrl,
  101. SourceUrl,
  102. CoverImgUrl,
  103. CoverImgUrl_1_1,
  104. CoverImgUrl_235_1,
  105. ItemShowType,
  106. IsOriginal,
  107. ShowDesc,
  108. ori_content,
  109. show_view_count,
  110. show_like_count,
  111. show_zs_count,
  112. show_pay_count,
  113. wx_sn,
  114. json.dumps(baseInfo, ensure_ascii=False),
  115. Functions().str_to_md5(title),
  116. status
  117. )
  118. try:
  119. insert_sql = f"""
  120. INSERT INTO {ARTICLE_TABLE}
  121. (ghId, accountName, appMsgId, title, Type, createTime, updateTime, Digest, ItemIndex, ContentUrl, SourceUrl, CoverImgUrl, CoverImgUrl_1_1, CoverImgUrl_255_1, ItemShowType, IsOriginal, ShowDesc, ori_content, show_view_count, show_like_count, show_zs_count, show_pay_count, wx_sn, baseInfo, title_md5, status)
  122. values
  123. (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s);
  124. """
  125. db_client.update(sql=insert_sql, params=info_tuple)
  126. log(
  127. task="updatePublishedMsgDaily",
  128. function="insert_each_msg",
  129. message="插入文章数据成功",
  130. data={
  131. "info": info_tuple
  132. }
  133. )
  134. except Exception as e:
  135. try:
  136. update_sql = f"""
  137. UPDATE {ARTICLE_TABLE}
  138. SET show_view_count = %s, show_like_count=%s
  139. WHERE wx_sn = %s;
  140. """
  141. db_client.update(sql=update_sql,
  142. params=(show_view_count, show_like_count, wx_sn))
  143. log(
  144. task="updatePublishedMsgDaily",
  145. function="insert_each_msg",
  146. message="更新文章数据成功",
  147. data={
  148. "wxSn": wx_sn,
  149. "likeCount": show_like_count,
  150. "viewCount": show_view_count
  151. }
  152. )
  153. except Exception as e:
  154. log(
  155. task="updatePublishedMsgDaily",
  156. function="insert_each_msg",
  157. message="更新文章失败, 报错原因是: {}".format(e),
  158. status="fail"
  159. )
  160. continue
  161. def update_each_account(db_client, account_info, account_name, latest_update_time, cursor=None):
  162. """
  163. 更新每一个账号信息
  164. :param account_info:
  165. :param account_name:
  166. :param cursor:
  167. :param latest_update_time: 最新更新时间
  168. :param db_client: 数据库连接信息
  169. :return: None
  170. """
  171. gh_id = account_info['ghId']
  172. response = WeixinSpider().update_msg_list(ghId=gh_id, index=cursor)
  173. msg_list = response.get("data", {}).get("data", {})
  174. if msg_list:
  175. # do
  176. last_article_in_this_msg = msg_list[-1]
  177. last_time_stamp_in_this_msg = last_article_in_this_msg['AppMsg']['BaseInfo']['UpdateTime']
  178. last_url = last_article_in_this_msg['AppMsg']['DetailInfo'][0]['ContentUrl']
  179. resdata = WeixinSpider().get_account_by_url(last_url)
  180. check_id = resdata['data'].get('data', {}).get('wx_gh')
  181. if check_id == gh_id:
  182. insert_each_msg(
  183. db_client=db_client,
  184. account_info=account_info,
  185. account_name=account_name,
  186. msg_list=msg_list
  187. )
  188. if last_time_stamp_in_this_msg > latest_update_time:
  189. next_cursor = response['data']['next_cursor']
  190. return update_each_account(
  191. db_client=db_client,
  192. account_info=account_info,
  193. account_name=account_name,
  194. latest_update_time=latest_update_time,
  195. cursor=next_cursor
  196. )
  197. log(
  198. task="updatePublishedMsgDaily",
  199. function="update_each_account",
  200. message="账号文章更新成功",
  201. data=response
  202. )
  203. else:
  204. log(
  205. task="updatePublishedMsgDaily",
  206. function="update_each_account",
  207. message="账号文章更新失败",
  208. status="fail",
  209. data=response
  210. )
  211. return
  212. def check_account_info(db_client, gh_id, account_name):
  213. """
  214. 通过 gh_id查询视频信息
  215. :param account_name:
  216. :param db_client:
  217. :param gh_id:
  218. :return:
  219. """
  220. sql = f"""
  221. SELECT accountName, updateTime
  222. FROM {ARTICLE_TABLE}
  223. WHERE ghId = '{gh_id}'
  224. ORDER BY updateTime DESC LIMIT 1;
  225. """
  226. result = db_client.select(sql)
  227. if result:
  228. old_account_name, update_time = result[0]
  229. return {
  230. "account_name": old_account_name,
  231. "update_time": update_time,
  232. "account_type": "history"
  233. }
  234. else:
  235. return {
  236. "account_name": account_name,
  237. "update_time": int(time.time()) - 30 * 24 * 60 * 60,
  238. "account_type": "new"
  239. }
  240. def update_single_account(db_client, account_info):
  241. """
  242. :param account_info:
  243. :param db_client:
  244. :return:
  245. """
  246. gh_id = account_info['ghId']
  247. account_name = account_info['name']
  248. account_detail = check_account_info(db_client, gh_id, account_name)
  249. account_name = account_detail['account_name']
  250. update_time = account_detail['update_time']
  251. update_each_account(
  252. db_client=db_client,
  253. account_info=account_info,
  254. account_name=account_name,
  255. latest_update_time=update_time
  256. )
  257. def check_single_account(db_client, account_item):
  258. """
  259. 校验每个账号是否更新
  260. :param db_client:
  261. :param account_item:
  262. :return: True / False
  263. """
  264. gh_id = account_item['ghId']
  265. account_type = account_item['account_type']
  266. today_str = datetime.today().strftime("%Y-%m-%d")
  267. today_date_time = datetime.strptime(today_str, "%Y-%m-%d")
  268. today_timestamp = today_date_time.timestamp()
  269. sql = f"""
  270. SELECT updateTime
  271. FROM {ARTICLE_TABLE}
  272. WHERE ghId = '{gh_id}'
  273. ORDER BY updateTime
  274. DESC
  275. LIMIT 1;
  276. """
  277. try:
  278. latest_update_time = db_client.select(sql)[0][0]
  279. # 判断该账号当天发布的文章是否被收集
  280. if account_type in const.SUBSCRIBE_TYPE_SET:
  281. if int(latest_update_time) > int(today_timestamp):
  282. return True
  283. else:
  284. return False
  285. else:
  286. if int(latest_update_time) > int(today_timestamp) - 7 * 24 * 3600:
  287. return True
  288. else:
  289. return False
  290. except Exception as e:
  291. print("updateTime Error -- {}".format(e))
  292. return False
  293. def update_job():
  294. """
  295. 更新任务
  296. :return:
  297. """
  298. try:
  299. db_client = PQMySQL()
  300. except Exception as e:
  301. error_msg = traceback.format_exc()
  302. bot(
  303. title="更新文章任务连接数据库失败",
  304. detail={
  305. "error": e,
  306. "msg": error_msg
  307. }
  308. )
  309. return
  310. sub_accounts, server_accounts = get_accounts()
  311. s_count = 0
  312. f_count = 0
  313. for sub_item in tqdm(sub_accounts):
  314. try:
  315. update_single_account(db_client, sub_item)
  316. s_count += 1
  317. time.sleep(5)
  318. except Exception as e:
  319. f_count += 1
  320. log(
  321. task="updatePublishedMsgDaily",
  322. function="update_job",
  323. message="单个账号文章更新失败, 报错信息是: {}".format(e),
  324. status="fail",
  325. )
  326. log(
  327. task="updatePublishedMsgDaily",
  328. function="update_job",
  329. message="订阅号更新完成",
  330. data={
  331. "success": s_count,
  332. "fail": f_count
  333. }
  334. )
  335. if f_count / (s_count + f_count) > 0.3:
  336. bot(
  337. title="订阅号超过 30% 的账号更新失败",
  338. detail={
  339. "success": s_count,
  340. "fail": f_count,
  341. "failRate": f_count / (s_count + f_count)
  342. }
  343. )
  344. bot(
  345. title="更新每日发布文章任务完成通知",
  346. detail={
  347. "msg": "订阅号更新完成",
  348. "finish_time": datetime.today().__str__()
  349. },
  350. mention=False
  351. )
  352. for sub_item in tqdm(server_accounts):
  353. try:
  354. update_single_account(db_client, sub_item)
  355. time.sleep(5)
  356. except Exception as e:
  357. print(e)
  358. bot(
  359. title="更新每日发布文章任务完成通知",
  360. detail={
  361. "msg": "服务号更新完成",
  362. "finish_time": datetime.today().__str__()
  363. },
  364. mention=False
  365. )
  366. def check_job():
  367. """
  368. 校验任务
  369. :return:
  370. """
  371. try:
  372. db_client = PQMySQL()
  373. except Exception as e:
  374. error_msg = traceback.format_exc()
  375. bot(
  376. title="校验更新文章任务连接数据库失败",
  377. detail={
  378. "job": "check_job",
  379. "error": e,
  380. "msg": error_msg
  381. }
  382. )
  383. return
  384. sub_accounts, server_accounts = get_accounts()
  385. fail_list = []
  386. # account_list = sub_accounts + server_accounts
  387. account_list = sub_accounts
  388. # check and rework if fail
  389. for sub_item in tqdm(account_list):
  390. res = check_single_account(db_client, sub_item)
  391. if not res:
  392. update_single_account(db_client, sub_item)
  393. # check whether success and bot if fails
  394. for sub_item in tqdm(account_list):
  395. res = check_single_account(db_client, sub_item)
  396. if not res:
  397. sub_item.drop('account_type')
  398. sub_item.drop('account_auth')
  399. init_timestamp = sub_item.pop('account_init_timestamp')
  400. sub_item['account_init_date'] = datetime.fromtimestamp(init_timestamp).strftime('%Y-%m-%d %H:%M:%S')
  401. fail_list.append(sub_item)
  402. if fail_list:
  403. try:
  404. bot(
  405. title="日常报警, 存在账号更新失败",
  406. detail=fail_list
  407. )
  408. except Exception as e:
  409. print("Timeout Error: {}".format(e))
  410. else:
  411. bot(
  412. title="校验完成通知",
  413. mention=False,
  414. detail={
  415. "msg": "校验任务完成",
  416. "finish_time": datetime.today().__str__()
  417. }
  418. )
  419. def get_articles(db_client):
  420. """
  421. :return:
  422. """
  423. sql = f"""
  424. SELECT ContentUrl, wx_sn
  425. FROM {ARTICLE_TABLE}
  426. WHERE publish_timestamp in {(const.DEFAULT_STATUS, const.REQUEST_FAIL_STATUS)};"""
  427. response = db_client.select(sql)
  428. return response
  429. def update_publish_timestamp(db_client, row):
  430. """
  431. 更新发布时间戳 && minigram 信息
  432. :param db_client:
  433. :param row:
  434. :return:
  435. """
  436. url = row[0]
  437. wx_sn = row[1]
  438. try:
  439. response = WeixinSpider().get_article_text(url)
  440. response_code = response['code']
  441. if response_code == const.ARTICLE_DELETE_CODE:
  442. publish_timestamp_s = const.DELETE_STATUS
  443. root_source_id_list = []
  444. elif response_code == const.ARTICLE_ILLEGAL_CODE:
  445. publish_timestamp_s = const.ILLEGAL_STATUS
  446. root_source_id_list = []
  447. elif response_code == const.ARTICLE_SUCCESS_CODE:
  448. data = response['data']['data']
  449. publish_timestamp_ms = data['publish_timestamp']
  450. publish_timestamp_s = int(publish_timestamp_ms / 1000)
  451. mini_program = data.get('mini_program', [])
  452. if mini_program:
  453. root_source_id_list = [
  454. urllib.parse.parse_qs(
  455. urllib.parse.unquote(i['path'])
  456. )['rootSourceId'][0]
  457. for i in mini_program
  458. ]
  459. else:
  460. root_source_id_list = []
  461. else:
  462. publish_timestamp_s = const.UNKNOWN_STATUS
  463. root_source_id_list = []
  464. except Exception as e:
  465. publish_timestamp_s = const.REQUEST_FAIL_STATUS
  466. root_source_id_list = []
  467. error_msg = traceback.format_exc()
  468. print(e, error_msg)
  469. update_sql = f"""
  470. UPDATE {ARTICLE_TABLE}
  471. SET publish_timestamp = %s, root_source_id_list = %s
  472. WHERE wx_sn = %s;
  473. """
  474. db_client.update(
  475. sql=update_sql,
  476. params=(
  477. publish_timestamp_s,
  478. json.dumps(root_source_id_list, ensure_ascii=False),
  479. wx_sn
  480. ))
  481. if publish_timestamp_s == const.REQUEST_FAIL_STATUS:
  482. return row
  483. else:
  484. return None
  485. def get_article_detail_job():
  486. """
  487. 获取发布文章详情
  488. :return:
  489. """
  490. try:
  491. db_client = PQMySQL()
  492. except Exception as e:
  493. error_msg = traceback.format_exc()
  494. bot(
  495. title="获取文章详情任务连接数据库失败",
  496. detail={
  497. "job": "get_article_detail_job",
  498. "error": e,
  499. "msg": error_msg
  500. }
  501. )
  502. return
  503. article_tuple = get_articles(db_client)
  504. for article in tqdm(article_tuple):
  505. try:
  506. update_publish_timestamp(db_client=db_client, row=article)
  507. except Exception as e:
  508. print(e)
  509. error_msg = traceback.format_exc()
  510. print(error_msg)
  511. # check 一遍存在请求失败-1 && 0 的文章
  512. process_failed_articles = get_articles(db_client)
  513. fail_list = []
  514. if process_failed_articles:
  515. for article in tqdm(process_failed_articles):
  516. try:
  517. res = update_publish_timestamp(db_client=db_client, row=article)
  518. fail_list.append({"wx_sn": res[1], "url": res[0]})
  519. except Exception as e:
  520. print(e)
  521. error_msg = traceback.format_exc()
  522. print(error_msg)
  523. # 通过msgId 来修改publish_timestamp
  524. update_sql = f"""
  525. UPDATE {ARTICLE_TABLE} oav
  526. JOIN (
  527. SELECT appMsgId, MAX(publish_timestamp) AS publish_timestamp
  528. FROM {ARTICLE_TABLE}
  529. WHERE publish_timestamp > %s
  530. GROUP BY appMsgId
  531. ) vv
  532. ON oav.appMsgId = vv.appMsgId
  533. SET oav.publish_timestamp = vv.publish_timestamp
  534. WHERE oav.publish_timestamp <= %s;
  535. """
  536. affected_rows = db_client.update(
  537. sql=update_sql,
  538. params=(0, 0)
  539. )
  540. # 若还是无 publish_timestamp,用update_time当作 publish_timestamp
  541. update_sql_2 = f"""
  542. UPDATE {ARTICLE_TABLE}
  543. SET publish_timestamp = updateTime
  544. WHERE publish_timestamp < %s;
  545. """
  546. db_client.update(
  547. sql=update_sql_2,
  548. params=0
  549. )
  550. if fail_list:
  551. bot(
  552. title="更新文章任务,请求detail失败",
  553. detail=fail_list
  554. )
  555. def whether_title_unsafe(db_client, title):
  556. """
  557. 检查文章标题是否已经存在违规记录
  558. :param db_client:
  559. :param title:
  560. :return:
  561. """
  562. title_md5 = functions.str_to_md5(title)
  563. sql = f"""
  564. SELECT title_md5
  565. FROM article_unsafe_title
  566. WHERE title_md5 = '{title_md5}';
  567. """
  568. res = db_client.select(sql)
  569. if res:
  570. return True
  571. else:
  572. return False
  573. def monitor(run_date):
  574. """
  575. 监控任务, 监测周期为7天,监测文章是否被违规,若监测到违规文章,则进行告警
  576. :return:
  577. """
  578. try:
  579. pq_client = PQMySQL()
  580. lam_client = longArticlesMySQL()
  581. except Exception as e:
  582. error_msg = traceback.format_exc()
  583. bot(
  584. title="监控任务连接数据库失败",
  585. detail={
  586. "job": "monitor",
  587. "error": str(e),
  588. "msg": error_msg
  589. }
  590. )
  591. return
  592. if not run_date:
  593. run_date = datetime.today().strftime("%Y-%m-%d")
  594. monitor_start_timestamp = int(datetime.strptime(run_date, "%Y-%m-%d").timestamp()) - const.MONITOR_PERIOD
  595. select_sql = f"""
  596. SELECT ghId, accountName, title, ContentUrl, wx_sn, from_unixtime(publish_timestamp) AS publish_timestamp
  597. FROM {ARTICLE_TABLE}
  598. WHERE publish_timestamp >= {monitor_start_timestamp};
  599. """
  600. article_list = pq_client.select(select_sql)
  601. for article in tqdm(article_list, desc="monitor article list"):
  602. gh_id = article[0]
  603. account_name = article[1]
  604. title = article[2]
  605. # 判断标题是否存在违规记录
  606. if whether_title_unsafe(lam_client, title):
  607. continue
  608. url = article[3]
  609. wx_sn = article[4]
  610. publish_date = article[5]
  611. try:
  612. response = spider.get_article_text(url, is_cache=False)
  613. response_code = response['code']
  614. if response_code == const.ARTICLE_ILLEGAL_CODE:
  615. bot(
  616. title="文章违规告警",
  617. detail={
  618. "ghId": gh_id,
  619. "accountName": account_name,
  620. "title": title,
  621. "wx_sn": str(wx_sn),
  622. "publish_date": str(publish_date)
  623. },
  624. mention=False
  625. )
  626. aiditApi.delete_articles(
  627. gh_id=gh_id,
  628. title=title
  629. )
  630. except Exception as e:
  631. error_msg = traceback.format_exc()
  632. log(
  633. task="monitor",
  634. function="monitor",
  635. message="请求文章详情失败",
  636. data={
  637. "ghId": gh_id,
  638. "accountName": account_name,
  639. "title": title,
  640. "wx_sn": str(wx_sn),
  641. "error": str(e),
  642. "msg": error_msg
  643. }
  644. )
  645. def main():
  646. """
  647. main
  648. :return:
  649. """
  650. parser = ArgumentParser()
  651. parser.add_argument(
  652. name="--run_task",
  653. help="update: update_job, check: check_job, detail: get_article_detail_job, monitor: monitor")
  654. parser.add_argument(
  655. name="--run_date",
  656. help="--run_date %Y-%m-%d",
  657. )
  658. args = parser.parse_args()
  659. if args.run_task:
  660. run_task = args.run_task
  661. match run_task:
  662. case "update":
  663. update_job()
  664. case "check":
  665. check_job()
  666. case "detail":
  667. get_article_detail_job()
  668. case "monitor":
  669. if args.run_date:
  670. run_date = args.run_date
  671. else:
  672. run_date = None
  673. monitor(run_date)
  674. case _:
  675. print("No such task, input update: update_job, check: check_job, detail: get_article_detail_job")
  676. else:
  677. update_job()
  678. check_job()
  679. get_article_detail_job()
  680. if __name__ == '__main__':
  681. main()