Exemple #1
0
def init_accounts_cookies():
    if os.path.exists(COOKIES_SAVE_PATH):
        with open(COOKIES_SAVE_PATH, 'rb') as f:
            cookies_dict = pickle.load(f)
        return list(cookies_dict.keys())
    else:
        for account in accounts:
            print('preparing cookies for account {}'.format(account))
            # 拿到并保存Cookie
            get_cookie_from_network(account['id'], account['password'])

        print('checking account validation...')
        # 拿到所有登陆成功的 account 列表
        valid_accounts = get_valid_accounts()

        if len(valid_accounts) == len(accounts):
            print('all accounts checked valid... start scrap')
            return valid_accounts
        elif len(valid_accounts) < 1:
            print('error, not find valid accounts, please check accounts.')
            exit(0)
        elif len(valid_accounts) > 1:
            print('find valid accounts: ', valid_accounts)
            print('starting scrap..')
            return valid_accounts
def set_accounts_cookies():
    if os.path.exists(COOKIES_SAVE_PATH):
        pass
    else:
        for account in accounts:
            print('preparing cookies for account {}'.format(account))
            get_cookie_from_network(account['id'], account['password'])
        print('all accounts getting cookies finished. starting scrap..')
 def _init_accounts_cookies(self):
     """
     get all cookies for accounts, dump into pkl, this will only run once, if
     you update accounts, set update to True
     :return:
     """
     if self.update_cookies:
         for k, v in accounts:
             get_cookie_from_network(k, v)
         print('all accounts updated cookies finished. starting scrap..')
     else:
         if os.path.exists(COOKIES_SAVE_PATH):
             pass
         else:
             for k, v in accounts:
                 get_cookie_from_network(k, v)
             print(
                 'all accounts getting cookies finished. starting scrap..')
Exemple #4
0
 def _init_accounts_cookies(self):
     """
     get all cookies for accounts, dump into pkl, this will only run once, if
     you update accounts, set update to True
     :return:
     """
     if self.update_cookies:
         for account in accounts:
             print('preparing cookies for account {}'.format(account))
             get_cookie_from_network(account['id'], account['password'])
         print('all accounts getting cookies finished. starting scrap..')
     else:
         if os.path.exists(COOKIES_SAVE_PATH):
             pass
         else:
             for account in accounts:
                 print('preparing cookies for account {}'.format(account))
                 get_cookie_from_network(account['id'], account['password'])
             print('all accounts getting cookies finished. starting scrap..')
 def _init_accounts_cookies(self):
     """
     get all cookies for accounts, dump into pkl, this will only run once, if
     you update accounts, set update to True
     :return:
     """
     if self.update_cookies:
         for account in accounts:
             print('preparing cookies for account {}'.format(account))
             get_cookie_from_network(account['id'], account['password'])
         print('all accounts getting cookies finished. starting scrap..')
     else:
         if os.path.exists(COOKIES_SAVE_PATH):
             pass
         else:
             for account in accounts:
                 print('preparing cookies for account {}'.format(account))
                 get_cookie_from_network(account['id'], account['password'])
             print('all accounts getting cookies finished. starting scrap..')
def test():
    cookies = get_cookie_from_network(accounts[0]['id'],
                                      accounts[0]['password'])
    print(cookies)
Exemple #7
0
def test():
    cookies = get_cookie_from_network(accounts[0]['id'], accounts[0]['password'])
    print(cookies)