|
@@ -57,7 +57,7 @@ class SearchKey:
|
|
Common.logger(log_type, crawler).info("点击微信指数小程序消息")
|
|
Common.logger(log_type, crawler).info("点击微信指数小程序消息")
|
|
for i in range(2):
|
|
for i in range(2):
|
|
weixinzhishu.clickMouseButtonLeft(weixinzhishu_coord)
|
|
weixinzhishu.clickMouseButtonLeft(weixinzhishu_coord)
|
|
- time.sleep(1)
|
|
|
|
|
|
+ time.sleep(3)
|
|
|
|
|
|
close_wechat = window.findFirstR(AXSubrole="AXCloseButton", AXRole="AXButton")
|
|
close_wechat = window.findFirstR(AXSubrole="AXCloseButton", AXRole="AXButton")
|
|
close_wechat.Press()
|
|
close_wechat.Press()
|
|
@@ -101,8 +101,7 @@ class SearchKey:
|
|
return "未找到wechat_key"
|
|
return "未找到wechat_key"
|
|
else:
|
|
else:
|
|
for content in contents:
|
|
for content in contents:
|
|
- if content["host"] == "search.weixin.qq.com" and content["path"] == "/cgi-bin/wxaweb/wxindexgetusergroup":
|
|
|
|
- # if content["host"] == "search.weixin.qq.com" and content["path"] == "/cgi-bin/wxaweb/wxawebreport":
|
|
|
|
|
|
+ if content["host"] == "search.weixin.qq.com" and content["path"] == "/cgi-bin/wxaweb/wxawebreport":
|
|
# print(f"content:{content}")
|
|
# print(f"content:{content}")
|
|
text = content['request']['body']['text']
|
|
text = content['request']['body']['text']
|
|
search_key = json.loads(text)['search_key']
|
|
search_key = json.loads(text)['search_key']
|
|
@@ -112,7 +111,17 @@ class SearchKey:
|
|
"openid": openid,
|
|
"openid": openid,
|
|
}
|
|
}
|
|
return wechat_key_dict
|
|
return wechat_key_dict
|
|
- return "未找到wechat_key"
|
|
|
|
|
|
+ elif content["host"] == "search.weixin.qq.com" and content["path"] == "/cgi-bin/wxaweb/wxindexgetusergroup":
|
|
|
|
+ text = content['request']['body']['text']
|
|
|
|
+ search_key = json.loads(text)['search_key']
|
|
|
|
+ openid = json.loads(text)['openid']
|
|
|
|
+ wechat_key_dict = {
|
|
|
|
+ "search_key": search_key,
|
|
|
|
+ "openid": openid,
|
|
|
|
+ }
|
|
|
|
+ return wechat_key_dict
|
|
|
|
+ else:
|
|
|
|
+ return "未找到wechat_key"
|
|
except Exception as e:
|
|
except Exception as e:
|
|
Common.logger(log_type, crawler).error(f"get_wechat_key:{e}\n")
|
|
Common.logger(log_type, crawler).error(f"get_wechat_key:{e}\n")
|
|
|
|
|
|
@@ -152,8 +161,6 @@ class SearchKey:
|
|
try:
|
|
try:
|
|
Common.logger(log_type, crawler).info(f"清空 chlsfiles 文件夹")
|
|
Common.logger(log_type, crawler).info(f"清空 chlsfiles 文件夹")
|
|
cls.remove_chlsfile(log_type, crawler)
|
|
cls.remove_chlsfile(log_type, crawler)
|
|
- # Common.logger(log_type, crawler).info('启动微信指数小程序')
|
|
|
|
- # cls.start_wechat(log_type, crawler)
|
|
|
|
Common.logger(log_type, crawler).info('获取 wechat_key')
|
|
Common.logger(log_type, crawler).info('获取 wechat_key')
|
|
while True:
|
|
while True:
|
|
cls.start_wechat(log_type, crawler)
|
|
cls.start_wechat(log_type, crawler)
|
|
@@ -179,14 +186,18 @@ class SearchKey:
|
|
@classmethod
|
|
@classmethod
|
|
def main(cls, log_type, crawler):
|
|
def main(cls, log_type, crawler):
|
|
while True:
|
|
while True:
|
|
- cls.write_wechat_key(log_type, crawler)
|
|
|
|
- Common.logger('searchkey', 'weixinzhishu').info('休眠10秒\n')
|
|
|
|
- time.sleep(10)
|
|
|
|
|
|
+ try:
|
|
|
|
+ cls.write_wechat_key(log_type, crawler)
|
|
|
|
+ Common.logger('searchkey', 'weixinzhishu').info('休眠10秒\n')
|
|
|
|
+ time.sleep(10)
|
|
|
|
+ except Exception as e:
|
|
|
|
+ Common.logger(log_type, crawler).error(f"{e}\n")
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
if __name__ == "__main__":
|
|
# SearchKey.start_wechat("search", "weixinzhishu")
|
|
# SearchKey.start_wechat("search", "weixinzhishu")
|
|
# SearchKey.del_wechat_key("search", "weixinzhishu")
|
|
# SearchKey.del_wechat_key("search", "weixinzhishu")
|
|
# SearchKey.write_wechat_key("search", "weixinzhishu")
|
|
# SearchKey.write_wechat_key("search", "weixinzhishu")
|
|
|
|
+ # print(SearchKey.get_wechat_key("search", "weixinzhishu"))
|
|
SearchKey.main("search", "weixinzhishu")
|
|
SearchKey.main("search", "weixinzhishu")
|
|
pass
|
|
pass
|