{"id":10020987,"date":"2025-08-30T23:04:42","date_gmt":"2025-08-30T15:04:42","guid":{"rendered":"https:\/\/itmax.cn\/?p=10020987"},"modified":"2025-08-30T23:04:42","modified_gmt":"2025-08-30T15:04:42","slug":"%e5%be%ae%e4%bf%a1%e5%9f%9f%e5%90%8d%e6%a3%80%e6%b5%8b%e8%87%aa%e5%8a%a8%e5%8c%96-http-%e6%9c%8d%e5%8a%a1%e8%84%9a%e6%9c%ac%ef%bc%8c%e5%8f%af%e6%a3%80%e6%b5%8b%e5%9f%9f%e5%90%8d%e5%9c%a8%e5%be%ae","status":"publish","type":"post","link":"https:\/\/itmax.cn\/?p=10020987","title":{"rendered":"\u5fae\u4fe1\u57df\u540d\u68c0\u6d4b\u81ea\u52a8\u5316 HTTP \u670d\u52a1\u811a\u672c\uff0c\u53ef\u68c0\u6d4b\u57df\u540d\u5728\u5fae\u4fe1\u5185\u662f\u5426\u88ab\u5c01\u6216\u88ab\u62e6\u622a\uff08\u975e\u5b98\u65b9\u4e5f\u53ef\u4ee5\u68c0\u6d4b\uff09"},"content":{"rendered":"<h2>\u6458\u8981<\/h2>\n<p>\u5fae\u4fe1\u57df\u540d\u68c0\u6d4b\u81ea\u52a8\u5316 HTTP \u670d\u52a1\u811a\u672c\uff0c\u53ef\u68c0\u6d4b\u57df\u540d\u5728\u5fae\u4fe1\u5185\u662f\u5426\u88ab\u5c01\u6216\u88ab\u62e6\u622a\u3002<\/p>\n<p>\u652f\u6301\u68c0\u6d4b\u60c5\u51b5\u5305\u62ec\uff1a<\/p>\n<ul>\n<li><strong>\u5982\u9700\u6d4f\u89c8\uff0c\u8bf7\u957f\u6309\u7f51\u5740\u590d\u5236\u540e\u4f7f\u7528\u6d4f\u89c8\u5668\u8bbf\u95ee<\/strong><\/li>\n<li><strong>\u5df2\u505c\u6b62\u8bbf\u95ee\u8be5\u7f51\u9875<\/strong><\/li>\n<li><strong>\u5c06\u8981\u8bbf\u95ee<\/strong><\/li>\n<li><strong>\u975e\u5b98\u65b9\u7f51\u9875<\/strong><\/li>\n<li><strong>\u672a\u5907\u6848<\/strong><\/li>\n<\/ul>\n<h2>\u6280\u672f\u539f\u7406<\/h2>\n<p>\u4f7f\u7528<code>Python<\/code>\u811a\u672c\u81ea\u52a8\u5316\u63a7\u5236\u5fae\u4fe1\u7535\u8111\u7248\uff0c\u5b8c\u6210\u8bbf\u95ee\u7f51\u9875\u7684\u8fc7\u7a0b\uff0c\u89e3\u6790\u9875\u9762\u5185\u5bb9\uff0c\u5373\u53ef\u5f97\u5230\u68c0\u6d4b\u7ed3\u679c\u3002<\/p>\n<ul>\n<li>\u4f18\u70b9\uff1a\u51c6\u786e\uff1b<\/li>\n<li>\u7f3a\u70b9\uff1a\u9700\u8981\u6302\u673a\u3001\u5e76\u4e14\u54cd\u5e94\u901f\u5ea6\u6162\uff0c\u5927\u6982\u9700\u89813-5\u79d2\u5b8c\u6210\u4e00\u6b21\u68c0\u6d4b\uff1b<\/li>\n<\/ul>\n<h2>\u68c0\u6d4b\u7ed3\u679c<\/h2>\n<table>\n<thead>\n<tr>\n<th>\u989c\u8272<\/th>\n<th>\u9875\u9762 Title<\/th>\n<th>\u9875\u9762 Desc<\/th>\n<th>\u68c0\u6d4b\u7ed3\u679c<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\ud83d\udd34 \u7ea2\u8272\u62e6\u622a<\/td>\n<td>\u5df2\u505c\u6b62\u8bbf\u95ee\u8be5\u7f51\u9875<\/td>\n<td>\u7f51\u9875\u5305\u542b XXX \u5185\u5bb9\uff0c\u4e3a\u7ef4\u62a4\u7eff\u8272\u4e0a\u7f51\u73af\u5883\uff0c\u5df2\u505c\u6b62\u8bbf\u95ee\u3002<\/td>\n<td>\u62e6\u622a<\/td>\n<\/tr>\n<tr>\n<td>\ud83d\udd35 \u84dd\u8272\u5c01\u7981<\/td>\n<td>\u5c06\u8981\u8bbf\u95ee<\/td>\n<td>\u975e\u5fae\u4fe1\u5b98\u65b9\u7f51\u9875\uff0c\u8bf7\u786e\u8ba4\u662f\u5426\u7ee7\u7eed\u8bbf\u95ee\u3002<\/td>\n<td>\u62e6\u622a<\/td>\n<\/tr>\n<tr>\n<td>\u26aa \u767d\u8272\u5c01\u7981<\/td>\n<td>\u5982\u9700\u6d4f\u89c8\uff0c\u8bf7\u957f\u6309\u7f51\u5740\u590d\u5236\u540e\u4f7f\u7528\u6d4f\u89c8\u5668\u8bbf\u95ee<\/td>\n<td>\u9875\u9762 URL<\/td>\n<td>\u62e6\u622a<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<blockquote><p>\ud83d\udca1 \u4ee5\u4e0a\u60c5\u51b5\u5747\u53ef\u68c0\u6d4b\u51fa\u7ed3\u679c\u3002<\/p><\/blockquote>\n<h2>\u5982\u4f55\u4f7f\u7528<\/h2>\n<ol>\n<li><strong>\u767b\u5f55\u5fae\u4fe1\u7535\u8111\u7248<\/strong><\/li>\n<li>\u7248\u672c\u8981\u6c42\uff1a\u6700\u65b0\u7248 Windows \u5fae\u4fe1\uff08\u7248\u672c\u53f7 4.1.0.18\uff09<\/li>\n<li><strong>\u6253\u5f00\u4efb\u610f\u7f51\u9875<\/strong><\/li>\n<li>\u7a97\u53e3\u4fdd\u6301\u6700\u5c0f<\/li>\n<li>\u7a97\u53e3\u5de6\u4e0a\u89d2\u5230\u641c\u7d22\u6846\u4e2d\u95f4\u4f4d\u7f6e\uff1a265 \u50cf\u7d20<\/li>\n<\/ol>\n<ul>\n<li>\u793a\u4f8b\u622a\u56fe\uff1a<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"410\" height=\"469\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVdmjLk\" alt=\"image.png\" title=\"image.png\"><\/p>\n<h2>\u4ee3\u7801<\/h2>\n<pre><code>import uiautomation as auto\nimport pyautogui\nimport time\nimport json\nfrom http.server import BaseHTTPRequestHandler, HTTPServer\nfrom urllib.parse import urlparse, parse_qs\nimport pyperclip  # \u7528\u4e8e\u526a\u8d34\u677f\u64cd\u4f5c\n\ndef find_all_controls(control, results=None):\n    &quot;&quot;&quot;\u9012\u5f52\u6536\u96c6\u6240\u6709\u63a7\u4ef6&quot;&quot;&quot;\n    if results is None:\n        results = []\n\n    try:\n        if control.Exists(0.1):\n            results.append(control)\n            try:\n                children = control.GetChildren()\n            except:\n                children = []\n            for child in children:\n                find_all_controls(child, results)\n    except Exception:\n        pass\n\n    return results\n\ndef automate_url(url):\n    &quot;&quot;&quot;\u6267\u884c\u70b9\u51fb\u8f93\u5165URL\u548c\u83b7\u53d6\u63a7\u4ef6\u903b\u8f91&quot;&quot;&quot;\n    class_name_to_search = &quot;Chrome_WidgetWin_0&quot;\n    desktop = auto.GetRootControl()\n    controls = [c for c in desktop.GetChildren() if c.ClassName == class_name_to_search]\n\n    for ctrl in controls:\n        try:\n            rect = ctrl.BoundingRectangle\n            x = rect.left + 275\n            y = rect.top + 15\n\n            # \u9f20\u6807\u70b9\u51fb\n            pyautogui.moveTo(x, y, duration=0.3)\n            pyautogui.click()\n            \n            # \u76f4\u63a5\u5c06 URL \u653e\u5165\u526a\u8d34\u677f\u5e76\u7c98\u8d34\n            pyperclip.copy(url)\n            pyautogui.hotkey(&quot;ctrl&quot;, &quot;v&quot;)  # \u7c98\u8d34\n            pyautogui.press(&quot;enter&quot;)\n            time.sleep(2)  # \u7b49\u5f85\u9875\u9762\u52a0\u8f7d\n\n            # \u83b7\u53d6\u6240\u6709\u63a7\u4ef6\n            all_controls = find_all_controls(ctrl)\n            text_controls = [c.Name for c in all_controls if c.ControlTypeName == &quot;TextControl&quot; and c.Name]\n\n            if text_controls:\n                title_text = text_controls[0]\n                desc_text = &quot;\uff0c&quot;.join(text_controls[1:]) if len(text_controls) &gt; 1 else &quot;&quot;\n            else:\n                title_text = &quot;&quot;\n                desc_text = &quot;&quot;\n\n            blocked_phrases = [\n                &quot;\u5982\u9700\u6d4f\u89c8\uff0c\u8bf7\u957f\u6309\u7f51\u5740\u590d\u5236\u540e\u4f7f\u7528\u6d4f\u89c8\u5668\u8bbf\u95ee&quot;,\n                &quot;\u5df2\u505c\u6b62\u8bbf\u95ee\u8be5\u7f51\u9875&quot;,\n                &quot;\u5c06\u8981\u8bbf\u95ee&quot;\n            ]\n            if any(phrase in title_text for phrase in blocked_phrases):\n                return {&quot;code&quot;: -1, &quot;msg&quot;: &quot;\u62e6\u622a&quot;, &quot;url&quot;: url, &quot;ret&quot;: {&quot;title&quot;: title_text, &quot;desc&quot;: desc_text}}\n            else:\n                return {&quot;code&quot;: 0, &quot;msg&quot;: &quot;\u6b63\u5e38&quot;, &quot;url&quot;: url, &quot;ret&quot;: {&quot;title&quot;: title_text, &quot;desc&quot;: desc_text}}\n\n        except Exception as e:\n            return {&quot;code&quot;: -2, &quot;msg&quot;: f&quot;\u64cd\u4f5c\u5931\u8d25: {e}&quot;, &quot;url&quot;: url, &quot;ret&quot;: {&quot;title&quot;: &quot;&quot;, &quot;desc&quot;: &quot;&quot;}}\n\n# HTTP \u670d\u52a1\u5668\u90e8\u5206\u4fdd\u6301\u4e0d\u53d8\nclass MyHandler(BaseHTTPRequestHandler):\n    def do_GET(self):\n        parsed_path = urlparse(self.path)\n        query = parse_qs(parsed_path.query)\n        url = query.get(&quot;url&quot;, [&quot;&quot;])[0]\n\n        if not url:\n            self.send_response(400)\n            self.send_header(&quot;Content-type&quot;, &quot;application\/json&quot;)\n            self.end_headers()\n            self.wfile.write(json.dumps({&quot;code&quot;: -3, &quot;msg&quot;: &quot;\u7f3a\u5c11url\u53c2\u6570&quot;}).encode(&quot;utf-8&quot;))\n            return\n\n        result = automate_url(url)\n\n        self.send_response(200)\n        self.send_header(&quot;Content-type&quot;, &quot;application\/json&quot;)\n        self.end_headers()\n        self.wfile.write(json.dumps(result, ensure_ascii=False).encode(&quot;utf-8&quot;))\n\nif __name__ == &quot;__main__&quot;:\n    host = &quot;127.0.0.1&quot;\n    port = 8000\n    print(f&quot;\u670d\u52a1\u5668\u542f\u52a8: http:\/\/{host}:{port}&quot;)\n    server = HTTPServer((host, port), MyHandler)\n    server.serve_forever()<\/code><\/pre>\n<h2>\u542f\u52a8<code>HTTP<\/code>\u670d\u52a1<\/h2>\n<pre><code>python weixin_domain_check.py<\/code><\/pre>\n<h2>\u6d4f\u89c8\u5668\u8bbf\u95ee<\/h2>\n<pre><code>http:\/\/127.0.0.1:8000\/?url=\u4f60\u8981\u68c0\u6d4b\u7684\u57df\u540d\u6216\u94fe\u63a5<\/code><\/pre>\n<p><a href=\"https:\/\/segmentfault.com\/a\/1190000047225845\">https:\/\/segmentfault.com\/a\/1190000047225845<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6458\u8981 \u5fae\u4fe1\u57df\u540d\u68c0\u6d4b\u81ea\u52a8\u5316 HTTP \u670d\u52a1\u811a\u672c\uff0c\u53ef\u68c0\u6d4b\u57df\u540d\u5728\u5fae\u4fe1\u5185\u662f\u5426\u88ab\u5c01\u6216\u88ab\u62e6\u622a\u3002 \u652f\u6301\u68c0\u6d4b\u60c5\u51b5\u5305\u62ec\uff1a \u5982\u9700\u6d4f [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-10020987","post","type-post","status-publish","format-standard","hentry","category-share"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10020987","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10020987"}],"version-history":[{"count":0,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10020987\/revisions"}],"wp:attachment":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10020987"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10020987"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10020987"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}