Exemple #1
0
 def login_push_wait(self):
     """
         短时热启动
     """
     self.__session.cookies.update(
         requests_html.requests.utils.cookiejar_from_dict(
             {"login_frequency": "2"}))
     resp = self.get(API_webwxpushloginurl,
                     params={"uin": self.__session.cookies.get("wxuin")})
     self.__qr_code_uuid = resp.json()["uuid"]
     info(f"New UUID: [{self.__qr_code_uuid}]")
     return True
Exemple #2
0
 def get_contact(self):
     """
         获取基础联系人
     """
     resp = self.get(
         API_webwxgetcontact,
         params={
             "lang": "zh_CN",
             "pass_ticket": self.__auth_data["pass_ticket"],
             "r": Device.get_timestamp(),
             "seq": 0,
             "skey": self.__auth_data["skey"],
         },
     )
     self.__contacts = resp.json()
     create_json(self.__contacts, API_static_path / "contacts.json")
     info(f"Get friends: [{self.__contacts['MemberCount']}]")
Exemple #3
0
 def get_ticket(self):
     """
         获取个人信息票据并更新部分cookie
     """
     info(f"Redirect to --> {self.__get_ticket_url}")
     resp = self.get(
         self.__get_ticket_url,
         params={
             "fun": "new",
             "lang": "zh_CN",
             "_": Device.get_timestamp()
         },
     )
     info(
         f"Get Ticket:{requests_html.requests.utils.dict_from_cookiejar(resp.cookies)}"
     )
     self.__auth_data = Parser.get_auth_data(resp)
     self.__session.cookies.update(
         requests_html.requests.utils.cookiejar_from_dict(
             {"last_wxuin": self.__auth_data["wxuin"]}))
     if list(filter(lambda item: item[1], self.__auth_data.items())):
         return True
Exemple #4
0
def init_path(path):
    if not check_path(path):
        parent_path = os.path.dirname(path)
        os.makedirs(parent_path)
        info(f"create path: {parent_path}")
    return pathlib.Path(path)
Exemple #5
0
def checkTimes(msg="", level=3):
    timeStart = time.time()
    yield
    info(f"{msg} cost times: {round(time.time()-timeStart,level)}s")