{"id":310,"date":"2023-11-28T00:01:26","date_gmt":"2023-11-27T16:01:26","guid":{"rendered":"https:\/\/ciscohe.cc\/blog\/?p=310"},"modified":"2023-11-28T00:17:15","modified_gmt":"2023-11-27T16:17:15","slug":"%e4%bb%8a%e5%a4%a9%e4%b8%8a%e8%af%be%e6%97%a0%e8%81%8a%e5%86%99%e4%ba%86%e4%b8%80%e6%ae%b5python","status":"publish","type":"post","link":"https:\/\/ciscohe.cc\/blog\/%e4%bb%8a%e5%a4%a9%e4%b8%8a%e8%af%be%e6%97%a0%e8%81%8a%e5%86%99%e4%ba%86%e4%b8%80%e6%ae%b5python\/","title":{"rendered":"\u4eca\u5929\u4e0a\u8bfe\u65e0\u804a\u5199\u4e86\u4e00\u6bb5Python\u811a\u672c\u5728\u767d\u5ad6GPT\u65b9\u9762\u81ea\u7ed9\u81ea\u8db3"},"content":{"rendered":"\n<p>\u672c\u6765\u540e\u53f0\u7528 <a href=\"https:\/\/github.com\/mufeng510\/Free-ChatGPT-API\">mufeng510\/Free-ChatGPT-API: \u57fa\u4e8epandora\u7684ChatGPT API\uff0c\u5b9e\u73b0\u4e86pool token\u7684\u81ea\u52a8\u66f4\u65b0 (github.com)<\/a>\u7684Python\u811a\u672c\u597d\u597d\u7684\uff0c\u76f4\u5230&#8230;<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/ciscohe.cc\/blog\/wp-content\/uploads\/2023\/11\/1701100425-image-1024x585.png'><img class=\"lazyload lazyload-style-8\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"585\" data-original=\"https:\/\/ciscohe.cc\/blog\/wp-content\/uploads\/2023\/11\/1701100425-image-1024x585.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-319\" style=\"width:700px\"  sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/div><\/figure>\n<\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/ciscohe.cc\/blog\/wp-content\/uploads\/2023\/11\/1701096093-image.png'><img class=\"lazyload lazyload-style-8\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"868\" height=\"684\" data-original=\"https:\/\/ciscohe.cc\/blog\/wp-content\/uploads\/2023\/11\/1701096093-image.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-312\" style=\"width:541px;height:auto\"  sizes=\"auto, (max-width: 868px) 100vw, 868px\" \/><\/div><\/figure>\n<\/div>\n\n\n<p class=\"has-text-align-center\">\u55ef\uff1f<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/ciscohe.cc\/blog\/wp-content\/uploads\/2023\/11\/1701096327-1a67406c56db474fc200ba37d5727d6-473x1024.jpg'><img class=\"lazyload lazyload-style-8\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"473\" height=\"1024\" data-original=\"https:\/\/ciscohe.cc\/blog\/wp-content\/uploads\/2023\/11\/1701096327-1a67406c56db474fc200ba37d5727d6-473x1024.jpg\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-313\" style=\"width:230px\"  sizes=\"auto, (max-width: 473px) 100vw, 473px\" \/><\/div><\/figure>\n<\/div>\n\n\n<p class=\"has-text-align-center\">\u6b38<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/ciscohe.cc\/blog\/wp-content\/uploads\/2023\/11\/1701096843-9b908006a682f3c5756f90853bf602d-473x1024.jpg'><img class=\"lazyload lazyload-style-8\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"473\" height=\"1024\" data-original=\"https:\/\/ciscohe.cc\/blog\/wp-content\/uploads\/2023\/11\/1701096843-9b908006a682f3c5756f90853bf602d-473x1024.jpg\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-316\" style=\"width:230px\"  sizes=\"auto, (max-width: 473px) 100vw, 473px\" \/><\/div><\/figure>\n<\/div>\n\n\n<p>\u6240\u4ee5\u7528\u8d26\u53f7\u548c\u5bc6\u7801\u81ea\u52a8\u7eed\u671f\u514d\u8d39\u9006\u5411API\u7684\u670d\u52a1\u5931\u6548\u4e86\uff1a<\/p>\n\n\n\n<p>\u539f\u6765\u7684Python\u7eed\u671f\u811a\u672c\uff1a\u8d26\u53f7\u5bc6\u7801&#8212;>FakeOpen API\u83b7\u53d6Access Token (\u8fd9\u91cc\u5931\u6548\u4e86) &#8212;>\u83b7\u53d6\u65b0\u7684Share Token (\u5931\u8d25)&#8212;>\u66f4\u65b0Pool Token\u5931\u8d25<\/p>\n\n\n\n<p>\u4e0d\u8fc7\uff0c\u4e5f\u8fd8\u662f\u6709\u529e\u6cd5\u7684\uff0c\u5728FakeOpen\u767b\u9646\u7f51\u9875\u83b7\u53d6Session Token&#8212;>Python\u811a\u672c\uff1aSession Token&#8212;>FakeOpen API\u83b7\u53d6Access Token&#8212;>\u83b7\u53d6\u65b0\u7684Share Token&#8212;>\u66f4\u65b0Pool Token<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/ciscohe.cc\/blog\/wp-content\/uploads\/2023\/11\/1701099827-8ebf8f4654dfc23c6164a411270c37f-473x1024.jpg'><img class=\"lazyload lazyload-style-8\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"473\" height=\"1024\" data-original=\"https:\/\/ciscohe.cc\/blog\/wp-content\/uploads\/2023\/11\/1701099827-8ebf8f4654dfc23c6164a411270c37f-473x1024.jpg\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-317\" style=\"width:230px\"  sizes=\"auto, (max-width: 473px) 100vw, 473px\" \/><\/div><\/figure>\n<\/div>\n\n\n<p>\u597d\u7684\uff0c\u90a3\u5c31&#8230; \u5199\u4e2a\u65b0\u7684Python\u7eed\u671f\u811a\u672c\u5427\uff01\uff08\u4e5f\u501f\u9274\u4e86\u4e00\u4e0b\u539f\u4f5c\u8005\u7684\u811a\u672c\uff0c\u8c22\u8c22\u4ed6\u6559\u4f1a\u6211\u600e\u4e48\u7528Python\u5199POST Request\u548cJSON\u89e3\u6790\u548c\u8bfb\u5199\u6587\u4ef6\u4fdd\u5b58\uff09<\/p>\n\n\n\n<p>\u9996\u5148\u770b\u770b\u539f\u672c\u7684Python\u811a\u672c\uff08<a href=\"https:\/\/github.com\/mufeng510\/Free-ChatGPT-API\">mufeng510\/Free-ChatGPT-API: \u57fa\u4e8epandora\u7684ChatGPT API\uff0c\u5b9e\u73b0\u4e86pool token\u7684\u81ea\u52a8\u66f4\u65b0 (github.com)<\/a>\uff09:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># -*- coding: utf-8 -*-\n\n\nimport requests\nimport random\nimport string\nimport time\nimport re\nfrom os import path\nfrom pandora.openai.auth import Auth0\n\n\ndef run():\n    unique_name = generate_random_string(10)\n\n    expires_in = 0\n    current_dir = path.dirname(path.abspath(__file__))\n    credentials_file = path.join(current_dir, 'credentials.txt')\n    tokens_file = path.join(current_dir, 'tokens.txt')\n    share_tokens_file = path.join(current_dir, 'share_tokens.txt')\n    pool_token_file = path.join(current_dir, 'pool_token.txt')\n\n    # \u751f\u6210 share token\u3002\n    with open(credentials_file, 'r', encoding='utf-8') as f:\n        credentials = f.read().split('\\n')\n    credentials = &#91;credential.split(',', 1) for credential in credentials]\n\n    count = 0\n    token_keys = &#91;]\n    for credential in credentials:\n        # \u63a5\u53e3\u6709\u9650\u6d41\u3002\n        sleep_seconds = 15\n        print(f\"\u5f00\u59cb\u4f11\u7720 {sleep_seconds} \u79d2...\")\n        time.sleep(sleep_seconds)\n        print(\"\u4f11\u7720\u7ed3\u675f\uff0c\u7ee7\u7eed\u6267\u884c\u540e\u7eed\u4ee3\u7801\u3002\")\n        progress = '{}\/{}'.format(credentials.index(credential) + 1, len(credentials))\n        if not credential or len(credential) != 2:\n            continue\n\n        count += 1\n        username, password = credential&#91;0].strip(), credential&#91;1].strip()\n        print('Login begin: {}, {}'.format(username, progress))\n\n        token_info = {\n            'token': 'None',\n            'share_token': 'None',\n        }\n        token_keys.append(token_info)\n\n        try:\n            token_info&#91;'token'] = Auth0(username, password).auth(False)\n            print('Login success: {}, {}'.format(username, progress))\n        except Exception as e:\n            err_str = str(e).replace('\\n', '').replace('\\r', '').strip()\n            print('Login failed: {}, {}'.format(username, err_str))\n            token_info&#91;'token'] = err_str\n            continue\n\n        data = {\n            'unique_name': unique_name,\n            'access_token': token_info&#91;'token'],\n            'expires_in': expires_in,\n        }\n        resp = requests.post('https:\/\/ai.fakeopen.com\/token\/register', data=data)\n        if resp.status_code == 200:\n            token_info&#91;'share_token'] = resp.json()&#91;'token_key']\n            print('share token: {}'.format(token_info&#91;'share_token']))\n        else:\n            err_str = resp.text.replace('\\n', '').replace('\\r', '').strip()\n            print('share token failed: {}'.format(err_str))\n            token_info&#91;'share_token'] = err_str\n            continue\n\n    with open(tokens_file, 'w', encoding='utf-8') as f:\n        for token_info in token_keys:\n            f.write('{}\\n'.format(token_info&#91;'token']))\n\n    with open(share_tokens_file, 'w', encoding='utf-8') as f:\n        for token_info in token_keys:\n            f.write('{}\\n'.format(token_info&#91;'share_token']))\n            \n    # \u751f\u6210 pool token, \u5982\u679c\u5df2\u6709pool token\u5219\u66f4\u65b0, \u6ca1\u6709\u5219\u65b0\u5efa\u3002\n    with open(pool_token_file, 'r', encoding='utf-8') as f:\n        pool_token = f.read()\n    if(len(pool_token) == 0):\n        print(\"\u5f53\u524d\u4e0d\u5b58\u5728pool_token\")\n    else:\n        if(re.compile(r'pk-&#91;0-9a-zA-Z_\\-]{43}').match(pool_token)):\n            print('\u5df2\u5b58\u5728: pool token: {}'.format(pool_token))\n        else:\n            print('pool token: \u683c\u5f0f\u4e0d\u6b63\u786e\uff0c\u5c06\u91cd\u65b0\u751f\u6210')\n            pool_token = \"\"\n\n    # \u4ece token_keys \u5217\u8868\u4e2d\u7b5b\u9009\u51fa\u6709\u6548\u6570\u636e\n    filtered_tokens = &#91;token_info&#91;'share_token'] for token_info in token_keys if re.compile(r'fk-&#91;0-9a-zA-Z_\\-]{43}').match(token_info&#91;'share_token'])]\n    \n    with open(pool_token_file, 'w', encoding='utf-8') as f:\n        if len(filtered_tokens)==0:\n            # \u5982\u679c\u6ca1\u6709\u53ef\u7528\u8d26\u53f7\uff0c\u5219\u4f7f\u7528\u516c\u5171pool\u3002\n            print('\u53ef\u7528\u8d26\u53f7\uff0c\u8bf7\u68c0\u67e5\u540e\u91cd\u8bd5')\n        else:\n            data = {\n                'share_tokens': '\\n'.join(filtered_tokens),\n                'pool_token': pool_token\n            }\n            resp = requests.post('https:\/\/ai.fakeopen.com\/pool\/update', data=data)\n            if resp.status_code == 200:\n                result = resp.json()\n                print('pool token \u66f4\u65b0\u7ed3\u679c: count:{} pool_token:{}'.format(result&#91;'count'],result&#91;'pool_token']))\n                pool_token = result&#91;'pool_token']\n                f.write('{}'.format(pool_token))\n            else:\n                print('pool token \u66f4\u65b0\u5931\u8d25')\n        f.close()\n\n\ndef generate_random_string(length):\n    letters = string.ascii_letters\n    random_string = ''.join(random.choice(letters) for _ in range(length))\n    return random_string\n\nif __name__ == '__main__':\n    run()<\/code><\/pre>\n\n\n\n<p>\u597d\u50cf\u5f88\u590d\u6742\uff0c\u4f46\u662f\u4e0d\u8981\u7d27\uff0c\u6211\u6700\u8fd1\u627e\u5230\u4e86FakeOpen\u7684\u6587\u6863\uff01\u6574\u4f53\u8ddf\u7740\u5b83\u7684POST\u63a5\u53e3\u8bf7\u6c42\u7136\u540eJSON\u89e3\u6790\u4e0b\u5c31\u53ef\u4ee5\u4e86\u3002\u4f8b\u5982\u53d1Session Token\u83b7\u53d6Access Token\u7684POST\uff1a<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/ciscohe.cc\/blog\/wp-content\/uploads\/2023\/11\/1701100258-2-1024x514.png'><img class=\"lazyload lazyload-style-8\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"514\" data-original=\"https:\/\/ciscohe.cc\/blog\/wp-content\/uploads\/2023\/11\/1701100258-2-1024x514.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-318\" style=\"width:580px;height:auto\"  sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/div><\/figure>\n<\/div>\n\n\n<p><\/p>\n\n\n\n<p class=\"has-text-align-center\">\u5b98\u65b9\u6587\u6863\uff1a<a href=\"https:\/\/fakeopen.org\/Pandora\/\">Fakeopen API \u6587\u6863 | FakeOpen Doc<\/a><\/p>\n\n\n\n<p>\u597d\u7684\uff0c\u90a3\u5c31\u8d81Professor\u5728review\u8fc7\u53bb12 weeks\u6559\u4e86\u4ec0\u4e48\u8ba9\u6211\u6194\u60b4\u7684\u5185\u5bb9\u7684\u65f6\u5019\u5199\u51fa\u6765\u5427~<\/p>\n\n\n\n<p>\uff08\u5f00\u6e90\uff09<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># -*- coding: utf-8 -*-\nimport requests\nimport json\nimport random\nimport string\nimport time\nimport re\nimport os\n\ndef generate_random_string(length):\n    letters = string.ascii_letters\n    random_string = ''.join(random.choice(letters) for _ in range(length))\n    return random_string\n\ncurrent_dir = os.path.dirname(os.path.abspath(__file__))\nsession_file_path = os.path.join(current_dir, 'session.txt')\nshare_tokens_file = os.path.join(current_dir, 'share_tokens.txt')\npool_token_file = os.path.join(current_dir, 'pool_token.txt')\n\n# \u8bfb\u53d6 session_keys\nwith open(session_file_path, 'r', encoding='utf-8') as session_file:\n    session_keys_str = session_file.read().strip()\n\n# \u68c0\u67e5 session_keys_str \u662f\u5426\u5b58\u5728\nif not session_keys_str:\n    print(\"Error: Session keys are missing in session.txt\")\nelse:\n    # \u7528\u9017\u53f7\u5206\u9694\u5e76\u53bb\u9664\u4e24\u4fa7\u7a7a\u767d\u5b57\u7b26\n    session_keys = &#91;key.strip() for key in session_keys_str.split(',')]\n\n    # \u8f93\u51fa\u5206\u79bb\u540e\u7684 session_keys (For debugginh\n    #print('Key1:\\t', session_keys&#91;0])\n    #print('Key2:\\t', session_keys&#91;1])\n\n#Set up headers for POST (according to FakeOpen Document)\nheaders = {\n    'Content-Type': 'application\/x-www-form-urlencoded'\n}\n    \n#Counting number of loops\ncount = 0\n\n#Create share_tokens list to store Share Tokens as elements\nshare_tokens = &#91;]\n\n#For Loop: If n Session keys are found in session.txt, then n times of exections are proceeded to register n Share Tokens\nfor i in range(len(session_keys)):\n        #Loop + 1\n        count += 1\n\n        #1. Use POST to fetch access token by session token (Session Token-->Access Token)\n        playload_access_token = {\n\t    'session_token': session_keys&#91;i]\n        }\n        \n        response_access_token = requests.post('https:\/\/ai.fakeopen.com\/auth\/session', headers=headers , data=playload_access_token)\n        \n        #200 OK?\n        if response_access_token.status_code == 200:\n            print('Get Access Token ({}\/{})'.format(count,len(session_keys)))\n        else:\n            err_str = response_access_token.text.replace('\\n', '').replace('\\r', '').strip()\n            print('Failed to get Access Token: {}'.format(err_str))\n            continue\n        #Debug response_access_token\n        #print(response_access_token.text)\n\n        list_access_token = json.loads(response_access_token.text)\n        access_token = list_access_token&#91;'access_token']\n        \n        #No need expires_in anymore\n        #expires_in = list_access_token&#91;'expires_in']\n\n        #Function for generating unique token names\n        unique_name = generate_random_string(10)\n\n        #2. Use POST to fetch share token by access token (Access Token-->Share Token)\n        playload_share_tokens = {\n            'unique_name': unique_name,\n            'access_token': access_token\n        }\n\n        response_share_tokens = requests.post('https:\/\/ai.fakeopen.com\/token\/register', headers=headers, data=playload_share_tokens)\n        \n        #200 OK?\n        if response_share_tokens.status_code == 200:\n            #I put all remaining code here\n            list_share_tokens = json.loads(response_share_tokens.text)\n            print('Get Share token\uff1a{} ({}\/{})'.format(list_share_tokens&#91;'token_key'],count,len(session_keys)))\n            share_tokens.append(list_share_tokens&#91;'token_key'])\n        else:\n            err_str = response_share_tokens.text.replace('\\n', '').replace('\\r', '').strip()\n            print('Failed to get Share Token: {}'.format(err_str))\n            continue\n#End of for-loop\n\n#Write string to txt\nwith open(share_tokens_file, 'w', encoding='utf-8') as f:\n        #Write share_tokens&#91;0], share_tokens&#91;1], share_tokens&#91;2], ... share_tokens&#91;n-1] elements of Share Tokens into share_tokens.txt\n        for token in share_tokens:\n            f.write(f\"{token}\\n\") #\u5199\u5165\u5230share_tokens.txt\nprint('\u5199\u5165share tokens\u5230share_tokens.txt\u5b8c\u6210')\n\n# \u751f\u6210 pool token, \u5982\u679c\u5df2\u6709pool token\u5219\u66f4\u65b0, \u6ca1\u6709\u5219\u65b0\u5efa\u3002\nwith open(pool_token_file, 'r', encoding='utf-8') as f:\n    pool_token = f.read()\n    if(len(pool_token) == 0):\n        print(\"\u5f53\u524d\u4e0d\u5b58\u5728pool_token\")\n    else:\n        if(re.compile(r'pk-&#91;0-9a-zA-Z_\\-]{43}').match(pool_token)):\n            print('Already Exist: pool token: {}'.format(pool_token))\n        else:\n            print('pool token: \u683c\u5f0f\u4e0d\u6b63\u786e\uff0c\u5c06\u91cd\u65b0\u751f\u6210')\n            pool_token = \"\"\n            #How to generate a pool token\uff1f Good question. If there is no pool token in pool_token.txt, you can leave it blank. After updating (POST) to the FakeOpen server, the server will generate a new pool token which will be saved in pool_token.txt.         \n#3. Use POST to UPDATE pool token by share tokens (Share Token-->Pool Token)\nplayload_pool = {\n    'share_tokens': '\\n'.join(share_tokens), #According to FakeOpen Document\n    'pool_token': pool_token \n    #This is the pool token which does not change. This token can store bunch of share tokens. Regular Update pool token is necessary.\n\n}\n\nresponse_pool = requests.post('https:\/\/ai.fakeopen.com\/pool\/update', data=playload_pool)\nlist_pool_token = json.loads(response_pool.text)\n\n#Display Pool Token (Debugging)\n#print('Pool token: ',list_pool_token&#91;'pool_token'])\n\n#Write string to txt\nwith open(pool_token_file, 'w', encoding='utf-8') as f:\n            f.write(f\"{list_pool_token&#91;'pool_token']}\\n\") #\u5199\u5165\u5230share_tokens.txt\nprint('\u5199\u5165pool token\u5230pool_token.txt\u5b8c\u6210')\n\n<\/code><\/pre>\n\n\n\n<p>\u5f88\u597d\uff0c\u8dd1\u4e00\u4e0b\u770b\u770b\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/ciscohe.cc\/blog\/wp-content\/uploads\/2023\/11\/1701100464-1-1024x585.png'><img class=\"lazyload lazyload-style-8\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"585\" data-original=\"https:\/\/ciscohe.cc\/blog\/wp-content\/uploads\/2023\/11\/1701100464-1-1024x585.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-320\" style=\"width:840px;height:auto\"  sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/div><\/figure>\n\n\n\n<p>\u5f88\u597d\uff0c\u53c8\u6709API key\u53ef\u4ee5\u7528\u4e86\uff0c\u4e22\u53bb\u540e\u53f0\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/ciscohe.cc\/blog\/wp-content\/uploads\/2023\/11\/1701100536-image-1024x664.png'><img class=\"lazyload lazyload-style-8\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"664\" data-original=\"https:\/\/ciscohe.cc\/blog\/wp-content\/uploads\/2023\/11\/1701100536-image-1024x664.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-321\"  sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/div><\/figure>\n\n\n\n<p class=\"has-text-align-center\">ChatGPT\uff0c\u542f\u52a8\uff01<\/p>\n\n\n\n<p>(\u81f3\u4e8e\u8be6\u7ec6\u7684\u4f7f\u7528\u6559\u7a0b\uff0c\u6709\u7a7a\u518d\u8bb2\u89e3\u5427\uff0c\u61c2Python\u4ee3\u7801\u7684\u4e5f\u77e5\u9053\u6211\u600e\u4e48\u505a\u4e86(\u6211\u7684\u4ee3\u7801\u7a0b\u5ea6\u53ea\u662f\u4e2d\u5b66\u751f\u6c34\u5e73)\uff0c\u4e0d\u8fc7\u6709\u4e00\u9879\u6ce8\u610f\uff1asession.txt\u91cc\u9762\u5b58\u50a8\u7684session token\u5982\u679c\u6709\u591a\u4f59\u4e00\u4e2a\u7684\u8bdd\u8bf7\u7528\u82f1\u6587\u9017\u53f7\u5206\u5f00\u3002P.S. Session Token\u4e5f\u633a\u597d\uff0c\u4e09\u4e2a\u6708\u624d\u8fc7\u671f\uff0c\u6bd4Access Token\u53ea\u6709\u5341\u5929\u7684\u671f\u9650\u957f\u592a\u591a\u4e86\u3002)<\/p>\n\n\n\n<p>\u5176\u4ed6<a href=\"https:\/\/chat.ciscohe.cc\/\">ChatGPT (ciscohe.cc)<\/a> \u5386\u53f2\u66f4\u65b0: <a href=\"https:\/\/chat.ciscohe.cc\/update\/\">chat.ciscohe.cc\/update\/<\/a><\/p>\n\n\n\n<p>End.<\/p>\n\n\n\n<p>Last Edited at 0015hrs on 28\/11\/2023<\/p>\n","protected":false},"excerpt":{"rendered":"<p>FakeOpen\u63a5\u53e3\u5931\u6548\u7684\u89e3\u51b3\u65b9\u6cd5\uff08\u81ea\u521b\u811a\u672c\uff09<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-310","post","type-post","status-publish","format-standard","hentry","category-6"],"_links":{"self":[{"href":"https:\/\/ciscohe.cc\/blog\/wp-json\/wp\/v2\/posts\/310","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ciscohe.cc\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ciscohe.cc\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ciscohe.cc\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ciscohe.cc\/blog\/wp-json\/wp\/v2\/comments?post=310"}],"version-history":[{"count":0,"href":"https:\/\/ciscohe.cc\/blog\/wp-json\/wp\/v2\/posts\/310\/revisions"}],"wp:attachment":[{"href":"https:\/\/ciscohe.cc\/blog\/wp-json\/wp\/v2\/media?parent=310"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ciscohe.cc\/blog\/wp-json\/wp\/v2\/categories?post=310"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ciscohe.cc\/blog\/wp-json\/wp\/v2\/tags?post=310"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}