{"id":2854,"date":"2025-03-16T12:30:24","date_gmt":"2025-03-16T04:30:24","guid":{"rendered":"https:\/\/www.laixuexila.com\/?p=2854"},"modified":"2025-03-16T12:30:24","modified_gmt":"2025-03-16T04:30:24","slug":"python3-%e7%bd%91%e7%bb%9c%e7%bc%96%e7%a8%8b15%ef%bc%9awebsocket-%e4%b8%8e%e6%95%b0%e6%8d%ae%e5%ba%93%e7%bb%93%e5%90%88","status":"publish","type":"post","link":"https:\/\/www.laixuexila.com\/index.php\/2025\/03\/16\/python3-%e7%bd%91%e7%bb%9c%e7%bc%96%e7%a8%8b15%ef%bc%9awebsocket-%e4%b8%8e%e6%95%b0%e6%8d%ae%e5%ba%93%e7%bb%93%e5%90%88\/","title":{"rendered":"Python3 \u7f51\u7edc\u7f16\u7a0b15\uff1aWebSocket \u4e0e\u6570\u636e\u5e93\u7ed3\u5408"},"content":{"rendered":"\n<p>WebSocket \u7684\u4e00\u4e2a\u5f3a\u5927\u529f\u80fd\u662f\u80fd\u591f\u5b9e\u73b0\u5b9e\u65f6\u6570\u636e\u66f4\u65b0\u3002\u4e3a\u4e86\u5b9e\u73b0\u8fd9\u4e00\u76ee\u6807\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06 WebSocket \u670d\u52a1\u4e0e\u6570\u636e\u5e93\u7ed3\u5408\u4f7f\u7528\uff0c\u5b9e\u65f6\u540c\u6b65\u6570\u636e\u5230\u5ba2\u6237\u7aef\u3002\u8fd9\u79cd\u6a21\u5f0f\u901a\u5e38\u7528\u4e8e\u9700\u8981\u5b9e\u65f6\u66f4\u65b0\u4fe1\u606f\u7684\u5e94\u7528\u573a\u666f\uff0c\u6bd4\u5982\u80a1\u7968\u884c\u60c5\u3001\u4f53\u80b2\u8d5b\u4e8b\u6570\u636e\u6216\u793e\u4ea4\u5a92\u4f53\u5e94\u7528\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>15.1 \u4f7f\u7528 WebSocket \u4e0e\u6570\u636e\u5e93\u540c\u6b65<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>15.1.1 \u6570\u636e\u5e93\u53d8\u66f4\u89e6\u53d1 WebSocket \u5e7f\u64ad<\/strong><\/h3>\n\n\n\n<p>\u5982\u679c\u4f60\u5e0c\u671b\u5728\u6570\u636e\u5e93\u53d1\u751f\u53d8\u5316\u65f6\uff0c\u7acb\u5373\u5c06\u53d8\u5316\u63a8\u9001\u7ed9\u6240\u6709\u8fde\u63a5\u7684\u5ba2\u6237\u7aef\uff0c\u53ef\u4ee5\u4f7f\u7528\u6570\u636e\u5e93\u89e6\u53d1\u5668\u6216\u8005\u540e\u53f0\u4efb\u52a1\u6765\u76d1\u63a7\u6570\u636e\u5e93\u7684\u53d8\u5316\uff0c\u7136\u540e\u901a\u8fc7 WebSocket \u901a\u77e5\u5ba2\u6237\u7aef\u3002\u5e38\u89c1\u7684\u5b9e\u73b0\u65b9\u5f0f\u6709\u4ee5\u4e0b\u51e0\u79cd\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u8f6e\u8be2\u6570\u636e\u5e93<\/strong>\uff1a\u5b9a\u671f\u67e5\u8be2\u6570\u636e\u5e93\u5e76\u5c06\u53d8\u5316\u63a8\u9001\u7ed9\u5ba2\u6237\u7aef\u3002<\/li>\n\n\n\n<li><strong>\u6570\u636e\u5e93\u89e6\u53d1\u5668\u4e0e\u6d88\u606f\u961f\u5217<\/strong>\uff1a\u901a\u8fc7\u6570\u636e\u5e93\u89e6\u53d1\u5668\u6216\u8005\u4e8b\u4ef6\u76d1\u542c\uff0c\u5c06\u53d8\u5316\u63a8\u9001\u5230\u6d88\u606f\u961f\u5217\u4e2d\uff0c\u540e\u53f0\u4efb\u52a1\u4ece\u6d88\u606f\u961f\u5217\u4e2d\u53d6\u51fa\u53d8\u5316\u5e76\u901a\u8fc7 WebSocket \u8fdb\u884c\u63a8\u9001\u3002<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>15.1.2 \u4f7f\u7528 PostgreSQL \u7684 LISTEN\/NOTIFY<\/strong><\/h3>\n\n\n\n<p>PostgreSQL \u63d0\u4f9b\u4e86 <code>LISTEN<\/code> \u548c <code>NOTIFY<\/code> \u547d\u4ee4\uff0c\u7528\u4e8e\u5b9e\u73b0\u6570\u636e\u5e93\u53d8\u66f4\u7684\u901a\u77e5\u673a\u5236\u3002\u901a\u8fc7\u8fd9\u4e9b\u547d\u4ee4\uff0c\u4f60\u53ef\u4ee5\u5728\u6570\u636e\u5e93\u4e2d\u76d1\u542c\u67d0\u4e2a\u4e8b\u4ef6\uff0c\u5e76\u901a\u8fc7 WebSocket \u63a8\u9001\u4e8b\u4ef6\u7ed9\u5ba2\u6237\u7aef\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>15.1.2.1 \u793a\u4f8b\uff1a\u5b9e\u73b0\u6570\u636e\u5e93\u53d8\u66f4\u901a\u77e5<\/strong><\/h4>\n\n\n\n<p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u4f1a\u4f7f\u7528 PostgreSQL \u6570\u636e\u5e93\u548c Python \u7684 <code>asyncpg<\/code> \u5e93\u6765\u5b9e\u73b0\u6570\u636e\u5e93\u7684\u53d8\u66f4\u901a\u77e5\uff0c\u5e76\u5c06\u901a\u77e5\u901a\u8fc7 WebSocket \u5e7f\u64ad\u7ed9\u6240\u6709\u8fde\u63a5\u7684\u5ba2\u6237\u7aef\u3002<\/p>\n\n\n\n<p>\u9996\u5148\uff0c\u5b89\u88c5 <code>asyncpg<\/code>\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install asyncpg<\/code><\/pre>\n\n\n\n<p>\u7136\u540e\uff0c\u521b\u5efa\u4e00\u4e2a PostgreSQL \u6570\u636e\u5e93\u89e6\u53d1\u5668\uff0c\u7528\u4e8e\u89e6\u53d1\u901a\u77e5\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>CREATE OR REPLACE FUNCTION notify_table_change() \nRETURNS trigger AS $$\nBEGIN\n  PERFORM pg_notify('table_change', 'Data has changed');\n  RETURN NEW;\nEND;\n$$ LANGUAGE plpgsql;\n\nCREATE TRIGGER table_change_trigger\nAFTER INSERT OR UPDATE OR DELETE ON your_table\nFOR EACH ROW EXECUTE FUNCTION notify_table_change();<\/code><\/pre>\n\n\n\n<p>\u63a5\u7740\uff0c\u5728 Python \u4e2d\u8bbe\u7f6e <code>LISTEN<\/code> \u548c <code>NOTIFY<\/code>\uff0c\u5f53\u6570\u636e\u5e93\u53d1\u751f\u53d8\u5316\u65f6\uff0c\u5c06\u901a\u77e5\u53d1\u9001\u7ed9 WebSocket \u5ba2\u6237\u7aef\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>15.1.2.2 Python \u4ee3\u7801\uff1a\u76d1\u542c\u6570\u636e\u5e93\u901a\u77e5\u5e76\u901a\u8fc7 WebSocket \u5e7f\u64ad<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>import asyncpg\nimport asyncio\nfrom fastapi import FastAPI, WebSocket\nfrom asyncpg.exceptions import PostgresError\n\napp = FastAPI()\n\n# \u7528\u4e8e\u4fdd\u5b58\u8fde\u63a5\u7684 WebSocket \u5ba2\u6237\u7aef\nclients = &#91;]\n\n# \u521b\u5efa\u6570\u636e\u5e93\u8fde\u63a5\u6c60\nasync def connect_to_db():\n    return await asyncpg.connect(user='youruser', password='yourpassword', database='yourdatabase')\n\n@app.websocket(\"\/ws\")\nasync def websocket_endpoint(websocket: WebSocket):\n    await websocket.accept()\n    clients.append(websocket)\n\n    # \u76d1\u542c\u6570\u636e\u5e93\u901a\u77e5\n    conn = await connect_to_db()\n    await conn.add_listener('table_change', handle_notify)\n\n    try:\n        while True:\n            message = await websocket.receive_text()\n            # Handle messages from client\n            print(message)\n    except Exception as e:\n        print(f\"Error: {e}\")\n    finally:\n        clients.remove(websocket)\n\n# \u5904\u7406 PostgreSQL \u901a\u77e5\u5e76\u5e7f\u64ad\u7ed9\u6240\u6709 WebSocket \u5ba2\u6237\u7aef\nasync def handle_notify(channel: str, payload: str):\n    print(f\"Received notification from DB: {payload}\")\n    for client in clients:\n        await client.send_text(f\"Database change detected: {payload}\")\n\n# \u542f\u52a8 FastAPI \u5e94\u7528\nif __name__ == '__main__':\n    import uvicorn\n    uvicorn.run(app, host=\"0.0.0.0\", port=8000)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>15.1.2.3 \u89e3\u91ca<\/strong><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u5728\u6570\u636e\u5e93\u4e2d\u521b\u5efa\u4e86\u4e00\u4e2a\u89e6\u53d1\u5668\uff0c\u5f53\u6570\u636e\u53d8\u66f4\u65f6\uff0c\u89e6\u53d1\u5668\u4f1a\u8c03\u7528 <code>notify_table_change()<\/code> \u51fd\u6570\uff0c\u5e76\u901a\u8fc7 <code>pg_notify()<\/code> \u5411\u76d1\u542c\u8005\u53d1\u9001\u901a\u77e5\u3002<\/li>\n\n\n\n<li>\u5728 Python \u4e2d\u4f7f\u7528 <code>asyncpg<\/code> \u8fde\u63a5 PostgreSQL\uff0c\u5e76\u901a\u8fc7 <code>add_listener<\/code> \u76d1\u542c\u6570\u636e\u5e93\u7684 <code>table_change<\/code> \u901a\u9053\u3002\u5f53\u6570\u636e\u53d8\u5316\u65f6\uff0c<code>handle_notify<\/code> \u51fd\u6570\u4f1a\u88ab\u8c03\u7528\uff0c\u5e76\u901a\u8fc7 WebSocket \u5411\u6240\u6709\u8fde\u63a5\u7684\u5ba2\u6237\u7aef\u5e7f\u64ad\u901a\u77e5\u3002<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>15.2 \u4f7f\u7528\u6d88\u606f\u961f\u5217\u540c\u6b65\u6570\u636e<\/strong><\/h2>\n\n\n\n<p>\u53e6\u4e00\u79cd\u5e38\u89c1\u7684\u65b9\u6cd5\u662f\u4f7f\u7528\u6d88\u606f\u961f\u5217\u6765\u5904\u7406\u6570\u636e\u5e93\u53d8\u66f4\uff0c\u5e76\u5c06\u6570\u636e\u901a\u8fc7 WebSocket \u63a8\u9001\u5230\u5ba2\u6237\u7aef\u3002\u5e38\u7528\u7684\u6d88\u606f\u961f\u5217\u6709 <strong>RabbitMQ<\/strong>\u3001<strong>Kafka<\/strong> \u548c <strong>Redis Pub\/Sub<\/strong>\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>15.2.1 \u4f7f\u7528 Redis Pub\/Sub \u4e0e WebSocket<\/strong><\/h3>\n\n\n\n<p>Redis \u63d0\u4f9b\u4e86 Pub\/Sub\uff08\u53d1\u5e03\/\u8ba2\u9605\uff09\u673a\u5236\uff0c\u5141\u8bb8\u4e00\u4e2a\u8fdb\u7a0b\u53d1\u5e03\u6d88\u606f\uff0c\u5176\u4ed6\u8fdb\u7a0b\u8ba2\u9605\u8fd9\u4e2a\u6d88\u606f\u3002\u4f7f\u7528 Redis \u53ef\u4ee5\u8f7b\u677e\u5b9e\u73b0\u591a\u4e2a\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u4e4b\u95f4\u7684\u5b9e\u65f6\u901a\u4fe1\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>15.2.1.1 Redis \u8bbe\u7f6e<\/strong><\/h4>\n\n\n\n<p>\u9996\u5148\uff0c\u786e\u4fdd\u5df2\u5b89\u88c5 Redis \u5e76\u6b63\u5728\u8fd0\u884c\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u542f\u52a8 Redis \u670d\u52a1\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>redis-server<\/code><\/pre>\n\n\n\n<p>\u7136\u540e\uff0c\u5728 Python \u4e2d\u4f7f\u7528 <code>aioredis<\/code> \u5e93\u8fde\u63a5 Redis\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install aioredis<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>15.2.1.2 Python \u4ee3\u7801\uff1a\u4f7f\u7528 Redis Pub\/Sub \u63a8\u9001\u6d88\u606f<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>import aioredis\nfrom fastapi import FastAPI, WebSocket\nimport asyncio\n\napp = FastAPI()\n\n# \u7528\u4e8e\u4fdd\u5b58\u8fde\u63a5\u7684 WebSocket \u5ba2\u6237\u7aef\nclients = &#91;]\n\nasync def redis_subscriber():\n    # \u8fde\u63a5\u5230 Redis \u670d\u52a1\n    redis = await aioredis.create_redis_pool('redis:\/\/localhost')\n\n    # \u8ba2\u9605 \"table_changes\" \u9891\u9053\n    res = await redis.subscribe('table_changes')\n\n    # \u5faa\u73af\u76d1\u542c Redis \u9891\u9053\u7684\u6d88\u606f\n    while True:\n        message = await res&#91;0].get()\n        print(f\"Received message from Redis: {message.decode()}\")\n\n        # \u5c06\u6d88\u606f\u5e7f\u64ad\u7ed9\u6240\u6709 WebSocket \u5ba2\u6237\u7aef\n        for client in clients:\n            await client.send_text(f\"Database change detected: {message.decode()}\")\n\n@app.websocket(\"\/ws\")\nasync def websocket_endpoint(websocket: WebSocket):\n    await websocket.accept()\n    clients.append(websocket)\n\n    # \u542f\u52a8 Redis \u8ba2\u9605\u8005\n    asyncio.create_task(redis_subscriber())\n\n    try:\n        while True:\n            message = await websocket.receive_text()\n            # Handle messages from client\n            print(message)\n    except Exception as e:\n        print(f\"Error: {e}\")\n    finally:\n        clients.remove(websocket)\n\n# \u542f\u52a8 FastAPI \u5e94\u7528\nif __name__ == '__main__':\n    import uvicorn\n    uvicorn.run(app, host=\"0.0.0.0\", port=8000)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>15.2.1.3 \u89e3\u91ca<\/strong><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><code>redis_subscriber()<\/code> \u51fd\u6570\u8fde\u63a5\u5230 Redis \u5e76\u8ba2\u9605 <code>table_changes<\/code> \u9891\u9053\uff0c\u7b49\u5f85\u6570\u636e\u5e93\u53d8\u66f4\u7684\u6d88\u606f\u3002<\/li>\n\n\n\n<li>\u5f53 Redis \u4e2d\u7684\u6d88\u606f\u53d1\u5e03\u65f6\uff0c<code>subscriber<\/code> \u51fd\u6570\u5c06\u63a5\u6536\u5230\u7684\u6d88\u606f\u5e7f\u64ad\u7ed9\u6240\u6709\u8fde\u63a5\u7684 WebSocket \u5ba2\u6237\u7aef\u3002<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>15.3 \u6027\u80fd\u4f18\u5316<\/strong><\/h2>\n\n\n\n<p>\u5f53 WebSocket \u548c\u6570\u636e\u5e93\u7ed3\u5408\u65f6\uff0c\u9700\u8981\u6ce8\u610f\u4ee5\u4e0b\u51e0\u70b9\u6765\u4f18\u5316\u6027\u80fd\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u907f\u514d\u8fc7\u5ea6\u8f6e\u8be2\u6570\u636e\u5e93<\/strong>\uff1a\u53ef\u4ee5\u4f7f\u7528\u6570\u636e\u5e93\u7684\u901a\u77e5\u673a\u5236\uff0c\u5982 PostgreSQL \u7684 <code>LISTEN\/NOTIFY<\/code>\uff0c\u800c\u4e0d\u662f\u8f6e\u8be2\u67e5\u8be2\u6570\u636e\u5e93\u3002<\/li>\n\n\n\n<li><strong>\u8fde\u63a5\u6c60\u548c\u6d88\u606f\u961f\u5217<\/strong>\uff1a\u4f7f\u7528\u8fde\u63a5\u6c60\u6765\u7ba1\u7406\u6570\u636e\u5e93\u8fde\u63a5\uff0c\u907f\u514d\u6bcf\u6b21\u6570\u636e\u5e93\u64cd\u4f5c\u65f6\u90fd\u521b\u5efa\u65b0\u7684\u8fde\u63a5\u3002\u6b64\u5916\uff0c\u5229\u7528\u6d88\u606f\u961f\u5217\u7cfb\u7edf\uff08\u5982 Redis \u6216 RabbitMQ\uff09\u6765\u89e3\u8026\u6570\u636e\u5e93\u64cd\u4f5c\u548c WebSocket \u63a8\u9001\uff0c\u63d0\u9ad8\u7cfb\u7edf\u7684\u53ef\u4f38\u7f29\u6027\u3002<\/li>\n\n\n\n<li><strong>\u8d1f\u8f7d\u5747\u8861<\/strong>\uff1a\u5bf9\u4e8e\u9ad8\u5e76\u53d1\u573a\u666f\uff0c\u4f7f\u7528\u8d1f\u8f7d\u5747\u8861\u5668\u5206\u53d1 WebSocket \u8fde\u63a5\uff0c\u5e76\u786e\u4fdd WebSocket \u670d\u52a1\u80fd\u591f\u5728\u591a\u4e2a\u5b9e\u4f8b\u4e4b\u95f4\u8fdb\u884c\u5206\u53d1\u3002<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><strong>\u603b\u7ed3\uff1a<\/strong><\/p>\n\n\n\n<p>\u901a\u8fc7\u5c06 WebSocket \u548c\u6570\u636e\u5e93\u7ed3\u5408\u4f7f\u7528\uff0c\u53ef\u4ee5\u5b9e\u73b0\u5b9e\u65f6\u6570\u636e\u540c\u6b65\u548c\u5e7f\u64ad\u529f\u80fd\u3002\u5728\u5b9e\u73b0\u65f6\uff0c\u6211\u4eec\u53ef\u4ee5\u5229\u7528 PostgreSQL \u7684 <code>LISTEN\/NOTIFY<\/code> \u673a\u5236\u6216 Redis \u7684 Pub\/Sub \u529f\u80fd\u6765\u76d1\u542c\u6570\u636e\u5e93\u53d8\u5316\uff0c\u5e76\u901a\u8fc7 WebSocket \u5e7f\u64ad\u6570\u636e\u7ed9\u5ba2\u6237\u7aef\u3002\u540c\u65f6\uff0c\u4f7f\u7528\u6d88\u606f\u961f\u5217\u548c\u8fde\u63a5\u6c60\u7b49\u4f18\u5316\u63aa\u65bd\u53ef\u4ee5\u63d0\u5347\u6027\u80fd\uff0c\u786e\u4fdd\u7cfb\u7edf\u7684\u53ef\u4f38\u7f29\u6027\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><strong>\u4e0b\u4e00\u6b65\uff1a\u6211\u4eec\u5c06\u63a2\u8ba8\u5982\u4f55\u90e8\u7f72 WebSocket \u5e94\u7528\u5e76\u8fdb\u884c\u9ad8\u53ef\u7528\u6027\u8bbe\u8ba1\uff01<\/strong> \ud83d\ude80<\/p>\n","protected":false},"excerpt":{"rendered":"<p>WebSocket \u7684\u4e00\u4e2a\u5f3a\u5927\u529f\u80fd\u662f\u80fd\u591f\u5b9e\u73b0\u5b9e\u65f6\u6570\u636e\u66f4\u65b0\u3002\u4e3a\u4e86\u5b9e\u73b0\u8fd9\u4e00\u76ee\u6807\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06 WebSocket \u670d [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2855,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[79],"tags":[],"class_list":["post-2854","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python-3-"],"_links":{"self":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts\/2854","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/comments?post=2854"}],"version-history":[{"count":1,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts\/2854\/revisions"}],"predecessor-version":[{"id":2856,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts\/2854\/revisions\/2856"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/media\/2855"}],"wp:attachment":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/media?parent=2854"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/categories?post=2854"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/tags?post=2854"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}