{ "cells": [ { "cell_type": "code", "execution_count": null, "id": "4dbde0c5", "metadata": {}, "outputs": [], "source": [ "import yaml\n", "\n", "\n", "with open(r'C:\\Users\\Klesh\\basicfiles\\cli\\scientific_surfing\\generated_config.yaml', 'r', encoding=\"utf-8\") as f:\n", " config = yaml.safe_load(f)" ] }, { "cell_type": "code", "execution_count": 8, "id": "16e45ae8", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{'cipher': 'rc4-md5', 'name': 'taiwan06', 'obfs': 'plain', 'obfs-param': '2c9120876.douyin.com', 'password': 'di15PV', 'port': 6506, 'protocol': 'auth_aes128_md5', 'protocol-param': '120876:VCgmuD', 'server': 'cdn02.0821.meituan88.com', 'type': 'ssr', 'udp': True}\n" ] } ], "source": [ "server = next(filter(lambda p: \"台湾06\" in p[\"name\"], config[\"proxies\"]))\n", "server[\"name\"] = \"taiwan06\"\n", "print(server)\n" ] }, { "cell_type": "code", "execution_count": 5, "id": "cc472edc", "metadata": {}, "outputs": [], "source": [ "config2 = config.copy()" ] }, { "cell_type": "code", "execution_count": 12, "id": "3db89abe", "metadata": {}, "outputs": [], "source": [ "config2[\"proxies\"] = [server]\n", "config2[\"proxy-groups\"] = {\n", " \"name\": \"defaultgroup\",\n", " \"type\": \"select\",\n", " \"proxies\": [server[\"name\"]],\n", "}\n", "config2[\"rules\"] = config[\"rules\"][:17]" ] }, { "cell_type": "code", "execution_count": 13, "id": "2630b0fc", "metadata": {}, "outputs": [], "source": [ "with open(r'C:\\Users\\Klesh\\basicfiles\\cli\\scientific_surfing\\simple.yaml', 'w', encoding=\"utf-8\") as f:\n", " yaml.dump(config2, f, default_flow_style=False, allow_unicode=True)" ] } ], "metadata": { "kernelspec": { "display_name": "scientific-surfing-4fYWmyKm-py3.12", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.10" } }, "nbformat": 4, "nbformat_minor": 5 }