gongzhonghao5_author.py 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. # -*- coding: utf-8 -*-
  2. # @Author: wangkun
  3. # @Time: 2023/3/28
  4. import datetime
  5. # import difflib
  6. import json
  7. import os
  8. import shutil
  9. import sys
  10. import time
  11. from hashlib import md5
  12. import requests
  13. import urllib3
  14. from selenium.webdriver import DesiredCapabilities
  15. from selenium.webdriver.chrome.service import Service
  16. from selenium.webdriver.common.by import By
  17. from selenium import webdriver
  18. sys.path.append(os.getcwd())
  19. from common.common import Common
  20. from common.feishu import Feishu
  21. from common.publish import Publish
  22. from common.scheduling_db import MysqlHelper
  23. from common.public import get_config_from_mysql, title_like, download_rule
  24. class GongzhonghaoAuthor5:
  25. platform = "公众号"
  26. # 获取 token
  27. @classmethod
  28. def get_token(cls, log_type, crawler, env):
  29. select_sql = f""" select * from crawler_config where source="{crawler}" and title LIKE "%公众号_5%";"""
  30. configs = MysqlHelper.get_values(log_type, crawler, select_sql, env, action="")
  31. if len(configs) == 0:
  32. # Common.logger(log_type, crawler).warning(f"公众号_3未配置token")
  33. Feishu.bot(log_type, crawler, "公众号_5:未配置token")
  34. time.sleep(60)
  35. return None
  36. token_dict = {
  37. "token_id": configs[0]["id"],
  38. "title": configs[0]["title"],
  39. "token": dict(eval(configs[0]["config"]))["token"],
  40. "cookie": dict(eval(configs[0]["config"]))["cookie"],
  41. "update_time": time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(int(configs[0]["update_time"]/1000))),
  42. "operator": configs[0]["operator"]
  43. }
  44. for k, v in token_dict.items():
  45. print(f"{k}:{v}")
  46. return token_dict
  47. @classmethod
  48. def get_users(cls, log_type, crawler, user_sheet, sheetid, i, env):
  49. user_name = user_sheet[i][0]
  50. wechat_name = user_sheet[i][2]
  51. if wechat_name is None or wechat_name.strip() == "" or wechat_name.replace(" ", "") == "":
  52. wechat_name = user_name
  53. out_uid = user_sheet[i][3]
  54. avatar_url = user_sheet[i][4]
  55. if out_uid is None or out_uid.strip() == "" or out_uid.replace(" ", "") == "":
  56. user_info_dict = cls.get_user_info(log_type=log_type, crawler=crawler, wechat_name=wechat_name, env=env)
  57. out_uid = user_info_dict["user_id"]
  58. avatar_url = user_info_dict["avatar_url"]
  59. Feishu.update_values(log_type, crawler, sheetid, f'D{i + 1}:E{i + 1}', [[out_uid, avatar_url]])
  60. our_user_dict = {
  61. 'user_name': user_name,
  62. 'user_id': out_uid,
  63. 'wechat_name': wechat_name,
  64. 'avatar_url': avatar_url,
  65. }
  66. for k, v in our_user_dict.items():
  67. Common.logger(log_type, crawler).info(f"{k}:{v}")
  68. return our_user_dict
  69. # 获取用户 fakeid
  70. @classmethod
  71. def get_user_info(cls, log_type, crawler, wechat_name, env):
  72. Common.logger(log_type, crawler).info(f"获取站外用户信息:{wechat_name}")
  73. while True:
  74. token_dict = cls.get_token(log_type, crawler, env)
  75. url = "https://mp.weixin.qq.com/cgi-bin/searchbiz?"
  76. headers = {
  77. "accept": "*/*",
  78. "accept-encoding": "gzip, deflate, br",
  79. "accept-language": "zh-CN,zh;q=0.9",
  80. "referer": "https://mp.weixin.qq.com/cgi-bin/appmsg?"
  81. "t=media/appmsg_edit_v2&action=edit&isNew=1"
  82. "&type=77&createType=5&token=1011071554&lang=zh_CN",
  83. 'sec-ch-ua': '" Not A;Brand";v="99", "Chromium";v="100", "Google Chrome";v="100"',
  84. "sec-ch-ua-mobile": "?0",
  85. "sec-ch-ua-platform": '"Windows"',
  86. "sec-fetch-dest": "empty",
  87. "sec-fetch-mode": "cors",
  88. "sec-fetch-site": "same-origin",
  89. "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
  90. " (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36",
  91. "x-requested-with": "XMLHttpRequest",
  92. 'cookie': token_dict['cookie'],
  93. }
  94. params = {
  95. "action": "search_biz",
  96. "begin": "0",
  97. "count": "5",
  98. "query": str(wechat_name),
  99. "token": token_dict['token'],
  100. "lang": "zh_CN",
  101. "f": "json",
  102. "ajax": "1",
  103. }
  104. urllib3.disable_warnings()
  105. r = requests.get(url=url, headers=headers, params=params, verify=False)
  106. r.close()
  107. if r.json()["base_resp"]["err_msg"] == "invalid session":
  108. Common.logger(log_type, crawler).warning(f"status_code:{r.status_code}")
  109. Common.logger(log_type, crawler).warning(f"get_fakeid:{r.text}\n")
  110. if 20 >= datetime.datetime.now().hour >= 10:
  111. Feishu.bot(log_type, crawler, f"{token_dict['title']}\n操作人:{token_dict['operator']}\n更换日期:{token_dict['update_time']} \n过期啦,请扫码更换token\nhttps://mp.weixin.qq.com/")
  112. time.sleep(60 * 10)
  113. continue
  114. if r.json()["base_resp"]["err_msg"] == "freq control":
  115. Common.logger(log_type, crawler).warning(f"status_code:{r.status_code}")
  116. Common.logger(log_type, crawler).warning(f"get_fakeid:{r.text}\n")
  117. if 20 >= datetime.datetime.now().hour >= 10:
  118. Feishu.bot(log_type, crawler, f"{token_dict['title']}\n操作人:{token_dict['operator']}\n更换日期:{token_dict['update_time']} \n频控啦,请扫码更换其他公众号token\nhttps://mp.weixin.qq.com/")
  119. time.sleep(60 * 10)
  120. continue
  121. if "list" not in r.json() or len(r.json()["list"]) == 0:
  122. Common.logger(log_type, crawler).warning(f"status_code:{r.status_code}")
  123. Common.logger(log_type, crawler).warning(f"get_fakeid:{r.text}\n")
  124. if 20 >= datetime.datetime.now().hour >= 10:
  125. Feishu.bot(log_type, crawler, f"{token_dict['title']}\n操作人:{token_dict['operator']}\n更换日期:{token_dict['update_time']} \n频控啦,请扫码更换其他公众号token\nhttps://mp.weixin.qq.com/")
  126. time.sleep(60 * 10)
  127. continue
  128. user_info_dict = {'user_name': r.json()["list"][0]["nickname"],
  129. 'user_id': r.json()["list"][0]["fakeid"],
  130. 'avatar_url': r.json()["list"][0]["round_head_img"]}
  131. return user_info_dict
  132. # 获取腾讯视频下载链接
  133. @classmethod
  134. def get_tencent_video_url(cls, video_id):
  135. url = 'https://vv.video.qq.com/getinfo?vids=' + str(video_id) + '&platform=101001&charge=0&otype=json'
  136. response = requests.get(url=url).text.replace('QZOutputJson=', '').replace('"};', '"}')
  137. response = json.loads(response)
  138. url = response['vl']['vi'][0]['ul']['ui'][0]['url']
  139. fvkey = response['vl']['vi'][0]['fvkey']
  140. video_url = url + str(video_id) + '.mp4?vkey=' + fvkey
  141. return video_url
  142. @classmethod
  143. def get_video_url(cls, article_url, env):
  144. # 打印请求配置
  145. ca = DesiredCapabilities.CHROME
  146. ca["goog:loggingPrefs"] = {"performance": "ALL"}
  147. # 不打开浏览器运行
  148. chrome_options = webdriver.ChromeOptions()
  149. chrome_options.add_argument("headless")
  150. chrome_options.add_argument(
  151. f'user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.79 Safari/537.36')
  152. chrome_options.add_argument("--no-sandbox")
  153. # driver初始化
  154. if env == "prod":
  155. driver = webdriver.Chrome(desired_capabilities=ca, options=chrome_options)
  156. else:
  157. driver = webdriver.Chrome(desired_capabilities=ca, options=chrome_options, service=Service(
  158. '/Users/wangkun/Downloads/chromedriver/chromedriver_v111/chromedriver'))
  159. driver.implicitly_wait(10)
  160. # Common.logger(log_type, crawler).info('打开文章链接')
  161. driver.get(article_url)
  162. time.sleep(1)
  163. if len(driver.find_elements(By.XPATH, '//div[@class="js_video_poster video_poster"]/*[2]')) != 0:
  164. video_url = driver.find_element(
  165. By.XPATH, '//div[@class="js_video_poster video_poster"]/*[2]').get_attribute('src')
  166. elif len(driver.find_elements(By.XPATH, '//span[@class="js_tx_video_container"]/*[1]')) != 0:
  167. iframe = driver.find_element(By.XPATH, '//span[@class="js_tx_video_container"]/*[1]').get_attribute(
  168. 'src')
  169. video_id = iframe.split('vid=')[-1].split('&')[0]
  170. video_url = cls.get_tencent_video_url(video_id)
  171. else:
  172. video_url = 0
  173. driver.quit()
  174. return video_url
  175. # 获取文章列表
  176. @classmethod
  177. def get_videoList(cls, log_type, crawler, rule_dict, user_dict, env):
  178. begin = 0
  179. while True:
  180. token_dict = cls.get_token(log_type, crawler, env)
  181. url = "https://mp.weixin.qq.com/cgi-bin/appmsg?"
  182. headers = {
  183. "accept": "*/*",
  184. "accept-encoding": "gzip, deflate, br",
  185. "accept-language": "zh-CN,zh;q=0.9",
  186. "referer": "https://mp.weixin.qq.com/cgi-bin/appmsg?"
  187. "t=media/appmsg_edit_v2&action=edit&isNew=1"
  188. "&type=77&createType=5&token=" + str(token_dict['token']) + "&lang=zh_CN",
  189. 'sec-ch-ua': '" Not A;Brand";v="99", "Chromium";v="100", "Google Chrome";v="100"',
  190. "sec-ch-ua-mobile": "?0",
  191. "sec-ch-ua-platform": '"Windows"',
  192. "sec-fetch-dest": "empty",
  193. "sec-fetch-mode": "cors",
  194. "sec-fetch-site": "same-origin",
  195. "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
  196. " (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36",
  197. "x-requested-with": "XMLHttpRequest",
  198. 'cookie': token_dict['cookie'],
  199. }
  200. params = {
  201. "action": "list_ex",
  202. "begin": str(begin),
  203. "count": "5",
  204. "fakeid": user_dict['user_id'],
  205. "type": "9",
  206. "query": "",
  207. "token": str(token_dict['token']),
  208. "lang": "zh_CN",
  209. "f": "json",
  210. "ajax": "1",
  211. }
  212. urllib3.disable_warnings()
  213. r = requests.get(url=url, headers=headers, params=params, verify=False)
  214. r.close()
  215. if r.json()["base_resp"]["err_msg"] == "invalid session":
  216. Common.logger(log_type, crawler).warning(f"status_code:{r.status_code}")
  217. Common.logger(log_type, crawler).warning(f"get_videoList:{r.text}\n")
  218. if 20 >= datetime.datetime.now().hour >= 10:
  219. Feishu.bot(log_type, crawler, f"{token_dict['title']}\n操作人:{token_dict['operator']}\n更换日期:{token_dict['update_time']}\n过期啦,请扫码更换token\nhttps://mp.weixin.qq.com/")
  220. time.sleep(60 * 10)
  221. continue
  222. if r.json()["base_resp"]["err_msg"] == "freq control":
  223. Common.logger(log_type, crawler).warning(f"status_code:{r.status_code}")
  224. Common.logger(log_type, crawler).warning(f"get_videoList:{r.text}\n")
  225. if 20 >= datetime.datetime.now().hour >= 10:
  226. Feishu.bot(log_type, crawler,f"{token_dict['title']}\n操作人:{token_dict['operator']}\n更换日期:{token_dict['update_time']} \n频控啦,请扫码更换其他公众号token\nhttps://mp.weixin.qq.com/")
  227. time.sleep(60 * 10)
  228. continue
  229. if 'app_msg_list' not in r.json():
  230. Common.logger(log_type, crawler).warning(f"status_code:{r.status_code}")
  231. Common.logger(log_type, crawler).warning(f"get_videoList:{r.text}\n")
  232. if 20 >= datetime.datetime.now().hour >= 10:
  233. Feishu.bot(log_type, crawler, f"{token_dict['title']}\n操作人:{token_dict['operator']}\n更换日期:{token_dict['update_time']}\n频控啦,请扫码更换其他公众号token\nhttps://mp.weixin.qq.com/")
  234. time.sleep(60 * 10)
  235. continue
  236. if len(r.json()['app_msg_list']) == 0:
  237. Common.logger(log_type, crawler).info('没有更多视频了\n')
  238. return
  239. else:
  240. begin += 5
  241. app_msg_list = r.json()['app_msg_list']
  242. for article in app_msg_list:
  243. try:
  244. create_time = article.get('create_time', 0)
  245. publish_time_stamp = int(create_time)
  246. publish_time_str = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(publish_time_stamp))
  247. article_url = article.get('link', '')
  248. video_dict = {
  249. 'video_id': article.get('aid', ''),
  250. 'video_title': article.get("title", "").replace(' ', '').replace('"', '').replace("'", ""),
  251. 'publish_time_stamp': publish_time_stamp,
  252. 'publish_time_str': publish_time_str,
  253. 'user_name': user_dict["user_name"],
  254. 'play_cnt': 0,
  255. 'comment_cnt': 0,
  256. 'like_cnt': 0,
  257. 'share_cnt': 0,
  258. 'user_id': user_dict['user_id'],
  259. 'avatar_url': user_dict['avatar_url'],
  260. 'cover_url': article.get('cover', ''),
  261. 'article_url': article.get('link', ''),
  262. 'video_url': cls.get_video_url(article_url, env),
  263. 'session': f'gongzhonghao-author1-{int(time.time())}'
  264. }
  265. for k, v in video_dict.items():
  266. Common.logger(log_type, crawler).info(f"{k}:{v}")
  267. if int(time.time()) - publish_time_stamp > 3600 * 24 * int(rule_dict.get('period', {}).get('max', 1000)):
  268. Common.logger(log_type, crawler).info(f"发布时间超过{int(rule_dict.get('period', {}).get('max', 1000))}天\n")
  269. return
  270. if video_dict['article_url'] == 0 or video_dict['video_url'] == 0:
  271. Common.logger(log_type, crawler).info("文章涉嫌违反相关法律法规和政策\n")
  272. # 标题敏感词过滤
  273. elif any(str(word) if str(word) in video_dict['video_title'] else False
  274. for word in get_config_from_mysql(log_type=log_type,
  275. source=crawler,
  276. env=env,
  277. text="filter",
  278. action="")) is True:
  279. Common.logger(log_type, crawler).info("标题已中过滤词\n")
  280. # 已下载判断
  281. elif cls.repeat_video(log_type, crawler, video_dict['video_id'], env) != 0:
  282. Common.logger(log_type, crawler).info("视频已下载\n")
  283. # 标题相似度
  284. elif title_like(log_type, crawler, video_dict['video_title'], cls.platform, env) is True:
  285. Common.logger(log_type, crawler).info(f'标题相似度>=80%:{video_dict["video_title"]}\n')
  286. else:
  287. cls.download_publish(log_type=log_type,
  288. crawler=crawler,
  289. video_dict=video_dict,
  290. rule_dict=rule_dict,
  291. # user_dict=user_dict,
  292. env=env)
  293. except Exception as e:
  294. Common.logger(log_type, crawler).error(f"抓取单条视频异常:{e}\n")
  295. Common.logger(log_type, crawler).info('休眠 60 秒\n')
  296. time.sleep(60)
  297. @classmethod
  298. def repeat_video(cls, log_type, crawler, video_id, env):
  299. sql = f""" select * from crawler_video where platform="公众号" and out_video_id="{video_id}"; """
  300. repeat_video = MysqlHelper.get_values(log_type, crawler, sql, env)
  301. return len(repeat_video)
  302. # 下载/上传
  303. @classmethod
  304. def download_publish(cls, log_type, crawler, video_dict, rule_dict, env):
  305. # 下载视频
  306. Common.download_method(log_type=log_type, crawler=crawler, text="video", title=video_dict["video_title"], url=video_dict["video_url"])
  307. md_title = md5(video_dict['video_title'].encode('utf8')).hexdigest()
  308. try:
  309. if os.path.getsize(f"./{crawler}/videos/{md_title}/video.mp4") == 0:
  310. # 删除视频文件夹
  311. shutil.rmtree(f"./{crawler}/videos/{md_title}")
  312. Common.logger(log_type, crawler).info("视频size=0,删除成功\n")
  313. return
  314. except FileNotFoundError:
  315. # 删除视频文件夹
  316. shutil.rmtree(f"./{crawler}/videos/{md_title}")
  317. Common.logger(log_type, crawler).info("视频文件不存在,删除文件夹成功\n")
  318. return
  319. # 获取视频时长
  320. ffmpeg_dict = Common.ffmpeg(log_type, crawler, f"./{crawler}/videos/{video_dict['video_title']}/video.mp4")
  321. video_dict["video_width"] = ffmpeg_dict["width"]
  322. video_dict["video_height"] = ffmpeg_dict["height"]
  323. video_dict["duration"] = ffmpeg_dict["duration"]
  324. Common.logger(log_type, crawler).info(f'video_width:{video_dict["video_width"]}')
  325. Common.logger(log_type, crawler).info(f'video_height:{video_dict["video_height"]}')
  326. Common.logger(log_type, crawler).info(f'duration:{video_dict["duration"]}')
  327. if download_rule(log_type, crawler, video_dict, rule_dict) is False:
  328. shutil.rmtree(f"./{crawler}/videos/{md_title}")
  329. Common.logger(log_type, crawler).info("不满足抓取规则,删除成功\n")
  330. return
  331. # 下载封面
  332. Common.download_method(log_type=log_type, crawler=crawler, text="cover",
  333. title=video_dict["video_title"], url=video_dict["cover_url"])
  334. # 保存视频信息至 "./videos/{video_title}/info.txt"
  335. Common.save_video_info(log_type=log_type, crawler=crawler, video_dict=video_dict)
  336. # 上传视频
  337. Common.logger(log_type, crawler).info("开始上传视频...")
  338. strategy = "定向爬虫策略"
  339. if env == 'prod':
  340. oss_endpoint = "inner"
  341. our_video_id = Publish.upload_and_publish(log_type=log_type,
  342. crawler=crawler,
  343. strategy=strategy,
  344. our_uid="follow",
  345. oss_endpoint=oss_endpoint,
  346. env=env)
  347. our_video_link = f"https://admin.piaoquantv.com/cms/post-detail/{str(our_video_id)}/info"
  348. else:
  349. oss_endpoint = "out"
  350. our_video_id = Publish.upload_and_publish(log_type=log_type,
  351. crawler=crawler,
  352. strategy=strategy,
  353. our_uid="follow",
  354. oss_endpoint=oss_endpoint,
  355. env=env)
  356. our_video_link = f"https://testadmin.piaoquantv.com/cms/post-detail/{str(our_video_id)}/info"
  357. if our_video_id is None:
  358. try:
  359. # 删除视频文件夹
  360. shutil.rmtree(f"./{crawler}/videos/{md_title}")
  361. return
  362. except FileNotFoundError:
  363. return
  364. insert_sql = f""" insert into crawler_video(video_id,
  365. out_user_id,
  366. platform,
  367. strategy,
  368. out_video_id,
  369. video_title,
  370. cover_url,
  371. video_url,
  372. duration,
  373. publish_time,
  374. play_cnt,
  375. crawler_rule,
  376. width,
  377. height)
  378. values({our_video_id},
  379. "{video_dict['user_id']}",
  380. "{cls.platform}",
  381. "定向爬虫策略",
  382. "{video_dict['video_id']}",
  383. "{video_dict['video_title']}",
  384. "{video_dict['cover_url']}",
  385. "{video_dict['video_url']}",
  386. {int(video_dict['duration'])},
  387. "{video_dict['publish_time_str']}",
  388. {int(video_dict['play_cnt'])},
  389. '{json.dumps(rule_dict)}',
  390. {int(video_dict['video_width'])},
  391. {int(video_dict['video_height'])}) """
  392. Common.logger(log_type, crawler).info(f"insert_sql:{insert_sql}")
  393. MysqlHelper.update_values(log_type, crawler, insert_sql, env)
  394. Common.logger(log_type, crawler).info('视频信息写入数据库成功')
  395. # 视频写入飞书
  396. Feishu.insert_columns(log_type, crawler, "47e39d", "ROWS", 1, 2)
  397. # 视频ID工作表,首行写入数据
  398. upload_time = int(time.time())
  399. values = [[time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(upload_time)),
  400. "用户主页",
  401. video_dict['video_title'],
  402. video_dict['video_id'],
  403. our_video_link,
  404. int(video_dict['duration']),
  405. f"{video_dict['video_width']}*{video_dict['video_height']}",
  406. video_dict['publish_time_str'],
  407. video_dict['user_name'],
  408. video_dict['user_id'],
  409. video_dict['avatar_url'],
  410. video_dict['cover_url'],
  411. video_dict['article_url'],
  412. video_dict['video_url']]]
  413. time.sleep(0.5)
  414. Feishu.update_values(log_type, crawler, "47e39d", "F2:Z2", values)
  415. Common.logger(log_type, crawler).info('视频下载/上传成功\n')
  416. @classmethod
  417. def get_all_videos(cls, log_type, crawler, rule_dict, env):
  418. while True:
  419. sheetid = "Bzv72P"
  420. user_sheet = Feishu.get_values_batch(log_type, crawler, sheetid)
  421. if user_sheet is None:
  422. Common.logger(log_type, crawler).warning(f"user_sheet:{user_sheet}, 2秒后重试")
  423. time.sleep(2)
  424. continue
  425. len_sheet = len(user_sheet)
  426. if len_sheet <= 401:
  427. Common.logger(log_type, crawler).info("抓取用户数<=400,无需启动第五套抓取脚本\n")
  428. return
  429. # if len_sheet >= 501:
  430. # len_sheet = 501
  431. for i in range(401, len_sheet):
  432. user_dict = cls.get_users(log_type=log_type,
  433. crawler=crawler,
  434. user_sheet=user_sheet,
  435. sheetid=sheetid,
  436. i=i,
  437. env=env)
  438. Common.logger(log_type, crawler).info(f'获取 {user_dict["user_name"]} 公众号视频\n')
  439. try:
  440. Common.logger(log_type, crawler).info(f'获取 {user_dict["user_name"]} 公众号视频\n')
  441. cls.get_videoList(log_type=log_type,
  442. crawler=crawler,
  443. rule_dict=rule_dict,
  444. user_dict=user_dict,
  445. env=env)
  446. Common.logger(log_type, crawler).info('休眠 60 秒\n')
  447. time.sleep(60)
  448. except Exception as e:
  449. Common.logger(log_type, crawler).info(f'抓取{user_dict["user_name"]}公众号时异常:{e}\n')
  450. if __name__ == "__main__":
  451. GongzhonghaoAuthor5.get_token("author", "gongzhonghao", "dev")
  452. # print(get_config_from_mysql("author", "gongzhonghao", "dev", "filter", action=""))
  453. pass