|
@@ -36,8 +36,10 @@ class Searchkey:
|
|
|
driver.implicitly_wait(10)
|
|
|
# Common.logger(log_type, crawler).info('点击微信指数')
|
|
|
driver.find_elements(By.NAME, '消息')[-1].click()
|
|
|
+ time.sleep(1)
|
|
|
+ driver.find_elements(By.NAME, '关闭')[-1].click()
|
|
|
# Common.logger(log_type, crawler).info('休眠 3 秒,退出微信')
|
|
|
- time.sleep(3)
|
|
|
+ time.sleep(1)
|
|
|
driver.quit()
|
|
|
except Exception as e:
|
|
|
Common.logger(log_type, crawler).error(f'start_wechat异常:{e}\n')
|
|
@@ -71,9 +73,11 @@ class Searchkey:
|
|
|
else:
|
|
|
for content in contents:
|
|
|
if content["host"] == "search.weixin.qq.com" and content["path"] == "/cgi-bin/wxaweb/wxindexgetusergroup":
|
|
|
+ print(f"content:{content}")
|
|
|
text = content['request']['body']['text']
|
|
|
search_key = json.loads(text)['search_key']
|
|
|
- return search_key
|
|
|
+ openid = json.loads(text)['openid']
|
|
|
+ return search_key, openid
|
|
|
except Exception as e:
|
|
|
Common.logger(log_type, crawler).exception(f"get_search_key异常:{e}\n")
|
|
|
return None
|
|
@@ -118,11 +122,11 @@ class Searchkey:
|
|
|
cls.start_wechat(log_type, crawler)
|
|
|
cls.get_search_key(log_type, crawler)
|
|
|
else:
|
|
|
- Common.logger(log_type, crawler).info(f'已获取 search_key:{search_key}')
|
|
|
+ Common.logger(log_type, crawler).info(f'已获取 search_key,openid:{search_key}')
|
|
|
Feishu.insert_columns(log_type, crawler, 'sVL74k', 'ROWS', 1, 2)
|
|
|
time.sleep(1)
|
|
|
time_str = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(int(time.time())))
|
|
|
- Feishu.update_values(log_type, crawler, 'sVL74k', 'A2:B2', [[time_str, search_key]])
|
|
|
+ Feishu.update_values(log_type, crawler, 'sVL74k', 'A2:Z2', [[time_str, search_key[0], search_key[-1]]])
|
|
|
cls.del_search_key_from_feishu(log_type, crawler)
|
|
|
Common.logger(log_type, crawler).info(f"search_key:{search_key}写入飞书表成功\n")
|
|
|
return
|