{"id":992294,"date":"2024-12-27T08:36:03","date_gmt":"2024-12-27T00:36:03","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/992294.html"},"modified":"2024-12-27T08:36:05","modified_gmt":"2024-12-27T00:36:05","slug":"python%e5%a6%82%e4%bd%95%e8%ae%be%e7%bd%ae%e4%bb%a3%e7%90%86ip","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/992294.html","title":{"rendered":"python\u5982\u4f55\u8bbe\u7f6e\u4ee3\u7406ip"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25070211\/013f0ef4-3221-4ba0-85fb-8a462c838a8c.webp\" alt=\"python\u5982\u4f55\u8bbe\u7f6e\u4ee3\u7406ip\" \/><\/p>\n<p><p> <strong>\u5728Python\u4e2d\u8bbe\u7f6e\u4ee3\u7406IP\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528\u7b2c\u4e09\u65b9\u5e93\u3001\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\u3001\u76f4\u63a5\u5728\u8bf7\u6c42\u4e2d\u6307\u5b9a\u7b49\u65b9\u5f0f\u6765\u5b9e\u73b0\u3002\u4f7f\u7528\u7b2c\u4e09\u65b9\u5e93\u5982<code>requests<\/code>\u3001<code>urllib<\/code>\u7b49\u53ef\u4ee5\u65b9\u4fbf\u5feb\u6377\u5730\u8bbe\u7f6e\u4ee3\u7406\uff0c\u9002\u5408\u4e0d\u540c\u573a\u666f\u7684\u9700\u6c42\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u4f7f\u7528<code>requests<\/code>\u5e93\u8bbe\u7f6e\u4ee3\u7406IP\u7684\u65b9\u6cd5\u3002<\/strong><\/p>\n<\/p>\n<p><p>\u4f7f\u7528<code>requests<\/code>\u5e93\u8bbe\u7f6e\u4ee3\u7406IP\u662fPython\u4e2d\u6700\u5e38\u7528\u7684\u65b9\u6cd5\u4e4b\u4e00\u3002<code>requests<\/code>\u662f\u4e00\u4e2a\u529f\u80fd\u5f3a\u5927\u4e14\u7b80\u5355\u6613\u7528\u7684HTTP\u5e93\uff0c\u53ef\u4ee5\u901a\u8fc7\u5728\u8bf7\u6c42\u4e2d\u6307\u5b9a<code>proxies<\/code>\u53c2\u6570\u6765\u8bbe\u7f6e\u4ee3\u7406\u3002\u4ee5\u4e0b\u662f\u8be6\u7ec6\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u4f7f\u7528 REQUESTS \u5e93\u8bbe\u7f6e\u4ee3\u7406<\/h3>\n<\/p>\n<p><h4>1\u3001\u5b89\u88c5 requests \u5e93<\/h4>\n<\/p>\n<p><p>\u5728\u4f7f\u7528<code>requests<\/code>\u5e93\u4e4b\u524d\uff0c\u9700\u8981\u786e\u4fdd\u5b83\u5df2\u7ecf\u5b89\u88c5\u5728\u4f60\u7684Python\u73af\u5883\u4e2d\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install requests<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001\u8bbe\u7f6e HTTP \u548c HTTPS \u4ee3\u7406<\/h4>\n<\/p>\n<p><p>\u5728\u4f7f\u7528<code>requests<\/code>\u5e93\u53d1\u9001HTTP\u8bf7\u6c42\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e<code>proxies<\/code>\u53c2\u6570\u6765\u6307\u5b9a\u4ee3\u7406IP\u3002<code>proxies<\/code>\u53c2\u6570\u662f\u4e00\u4e2a\u5b57\u5178\u7c7b\u578b\uff0c\u5305\u542b<code>http<\/code>\u548c<code>https<\/code>\u7684\u4ee3\u7406\u8bbe\u7f6e\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import requests<\/p>\n<p>proxies = {<\/p>\n<p>    &quot;http&quot;: &quot;http:\/\/your_http_proxy:port&quot;,<\/p>\n<p>    &quot;https&quot;: &quot;https:\/\/your_https_proxy:port&quot;,<\/p>\n<p>}<\/p>\n<p>response = requests.get(&quot;http:\/\/example.com&quot;, proxies=proxies)<\/p>\n<p>print(response.text)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u793a\u4f8b\u4e2d\uff0c<code>proxies<\/code>\u5b57\u5178\u6307\u5b9a\u4e86HTTP\u548cHTTPS\u8bf7\u6c42\u6240\u4f7f\u7528\u7684\u4ee3\u7406IP\u548c\u7aef\u53e3\u3002\u8fd9\u6837\uff0c\u5f53\u4f7f\u7528<code>requests.get()<\/code>\u53d1\u9001\u8bf7\u6c42\u65f6\uff0c\u6d41\u91cf\u5c06\u901a\u8fc7\u6307\u5b9a\u7684\u4ee3\u7406\u670d\u52a1\u5668\u8fdb\u884c\u8f6c\u53d1\u3002<\/p>\n<\/p>\n<p><h4>3\u3001\u5bf9\u4ee3\u7406\u8fdb\u884c\u8eab\u4efd\u9a8c\u8bc1<\/h4>\n<\/p>\n<p><p>\u6709\u4e9b\u4ee3\u7406\u670d\u52a1\u5668\u9700\u8981\u8fdb\u884c\u8eab\u4efd\u9a8c\u8bc1\uff0c\u8fd9\u65f6\u53ef\u4ee5\u5728\u4ee3\u7406URL\u4e2d\u5305\u542b\u7528\u6237\u540d\u548c\u5bc6\u7801\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">proxies = {<\/p>\n<p>    &quot;http&quot;: &quot;http:\/\/username:password@your_http_proxy:port&quot;,<\/p>\n<p>    &quot;https&quot;: &quot;https:\/\/username:password@your_https_proxy:port&quot;,<\/p>\n<p>}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u6837\uff0c<code>requests<\/code>\u5e93\u4f1a\u5728\u8bf7\u6c42\u4ee3\u7406\u65f6\u81ea\u52a8\u9644\u5e26\u8eab\u4efd\u9a8c\u8bc1\u4fe1\u606f\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u4f7f\u7528 URLLIB \u5e93\u8bbe\u7f6e\u4ee3\u7406<\/h3>\n<\/p>\n<p><p>\u867d\u7136<code>requests<\/code>\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u5e93\uff0c\u4f46\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c<code>urllib<\/code>\u5e93\u4e5f\u53ef\u4ee5\u7528\u4e8e\u8bbe\u7f6e\u4ee3\u7406\u3002\u4ee5\u4e0b\u662f\u4f7f\u7528<code>urllib<\/code>\u5e93\u7684\u65b9\u6cd5\uff1a<\/p>\n<\/p>\n<p><h4>1\u3001\u5bfc\u5165 urllib \u5e93<\/h4>\n<\/p>\n<p><p>Python\u6807\u51c6\u5e93\u4e2d\u5305\u542b<code>urllib<\/code>\u6a21\u5757\uff0c\u65e0\u9700\u989d\u5916\u5b89\u88c5\u3002\u53ef\u4ee5\u76f4\u63a5\u5bfc\u5165\u4f7f\u7528\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import urllib.request<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001\u8bbe\u7f6e\u4ee3\u7406<\/h4>\n<\/p>\n<p><p>\u901a\u8fc7\u521b\u5efa\u4e00\u4e2a\u4ee3\u7406\u5904\u7406\u5668\u5e76\u5c06\u5176\u6dfb\u52a0\u5230<code>urllib<\/code>\u7684<code>opener<\/code>\u4e2d\uff0c\u53ef\u4ee5\u5b9e\u73b0\u4ee3\u7406\u8bbe\u7f6e\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">proxy_support = urllib.request.ProxyHandler({<\/p>\n<p>    &#39;http&#39;: &#39;http:\/\/your_http_proxy:port&#39;,<\/p>\n<p>    &#39;https&#39;: &#39;https:\/\/your_https_proxy:port&#39;,<\/p>\n<p>})<\/p>\n<p>opener = urllib.request.build_opener(proxy_support)<\/p>\n<p>urllib.request.install_opener(opener)<\/p>\n<p>response = urllib.request.urlopen(&#39;http:\/\/example.com&#39;)<\/p>\n<p>print(response.read().decode(&#39;utf-8&#39;))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e09\u3001\u901a\u8fc7\u73af\u5883\u53d8\u91cf\u8bbe\u7f6e\u4ee3\u7406<\/h3>\n<\/p>\n<p><p>\u53e6\u4e00\u79cd\u8bbe\u7f6e\u4ee3\u7406\u7684\u65b9\u6cd5\u662f\u901a\u8fc7\u73af\u5883\u53d8\u91cf\u3002\u8fd9\u79cd\u65b9\u6cd5\u9002\u7528\u4e8e\u6240\u6709\u4f7f\u7528\u7cfb\u7edf\u7f51\u7edc\u5e93\u7684Python\u7a0b\u5e8f\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf<\/h4>\n<\/p>\n<p><p>\u5728\u64cd\u4f5c\u7cfb\u7edf\u7684\u73af\u5883\u53d8\u91cf\u4e2d\u8bbe\u7f6e<code>http_proxy<\/code>\u548c<code>https_proxy<\/code>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u5728Windows\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4\u884c\u8bbe\u7f6e\uff1a<\/li>\n<\/ul>\n<p><pre><code class=\"language-bash\">set http_proxy=http:\/\/your_http_proxy:port<\/p>\n<p>set https_proxy=https:\/\/your_https_proxy:port<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ul>\n<li>\u5728Linux\u6216macOS\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u7ec8\u7aef\u8bbe\u7f6e\uff1a<\/li>\n<\/ul>\n<p><pre><code class=\"language-bash\">export http_proxy=http:\/\/your_http_proxy:port<\/p>\n<p>export https_proxy=https:\/\/your_https_proxy:port<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001\u4f7f\u7528\u73af\u5883\u53d8\u91cf<\/h4>\n<\/p>\n<p><p>\u5728Python\u811a\u672c\u4e2d\uff0c\u76f4\u63a5\u8fdb\u884c\u7f51\u7edc\u8bf7\u6c42\uff0c\u7a0b\u5e8f\u4f1a\u81ea\u52a8\u4f7f\u7528\u8bbe\u7f6e\u7684\u4ee3\u7406\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import requests<\/p>\n<p>response = requests.get(&quot;http:\/\/example.com&quot;)<\/p>\n<p>print(response.text)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0c\u6240\u6709\u7684\u7f51\u7edc\u8bf7\u6c42\u5c06\u81ea\u52a8\u901a\u8fc7\u73af\u5883\u53d8\u91cf\u4e2d\u6307\u5b9a\u7684\u4ee3\u7406\u670d\u52a1\u5668\u8fdb\u884c\u8f6c\u53d1\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u4f7f\u7528 SOCKS \u4ee3\u7406<\/h3>\n<\/p>\n<p><p>\u6709\u65f6\u9700\u8981\u4f7f\u7528SOCKS\u4ee3\u7406\u8fdb\u884c\u7f51\u7edc\u8bf7\u6c42\uff0c\u8fd9\u65f6\u53ef\u4ee5\u501f\u52a9<code>requests[socks]<\/code>\u5e93\u6765\u5b9e\u73b0\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u5b89\u88c5 requests[socks]<\/h4>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u786e\u4fdd\u5b89\u88c5\u4e86\u652f\u6301SOCKS\u4ee3\u7406\u7684<code>requests<\/code>\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install requests[socks]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001\u8bbe\u7f6e SOCKS \u4ee3\u7406<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528SOCKS\u4ee3\u7406\u65f6\uff0c\u9700\u8981\u5728<code>proxies<\/code>\u53c2\u6570\u4e2d\u6307\u5b9a<code>http<\/code>\u6216<code>https<\/code>\u534f\u8bae\u4f7f\u7528\u7684SOCKS\u4ee3\u7406\u5730\u5740\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">proxies = {<\/p>\n<p>    &quot;http&quot;: &quot;socks5:\/\/your_socks_proxy:port&quot;,<\/p>\n<p>    &quot;https&quot;: &quot;socks5:\/\/your_socks_proxy:port&quot;,<\/p>\n<p>}<\/p>\n<p>response = requests.get(&quot;http:\/\/example.com&quot;, proxies=proxies)<\/p>\n<p>print(response.text)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0c<code>requests<\/code>\u5e93\u53ef\u4ee5\u65b9\u4fbf\u5730\u652f\u6301SOCKS\u4ee3\u7406\uff0c\u6ee1\u8db3\u7279\u5b9a\u573a\u666f\u4e0b\u7684\u9700\u6c42\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u4ee3\u7406\u7684\u6700\u4f73\u5b9e\u8df5<\/h3>\n<\/p>\n<p><p>\u5728\u4f7f\u7528\u4ee3\u7406IP\u8fdb\u884c\u7f51\u7edc\u8bf7\u6c42\u65f6\uff0c\u9700\u8981\u6ce8\u610f\u4ee5\u4e0b\u51e0\u70b9\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u9009\u62e9\u9ad8\u8d28\u91cf\u7684\u4ee3\u7406IP<\/strong>\uff1a\u4f7f\u7528\u7a33\u5b9a\u3001\u5feb\u901f\u7684\u4ee3\u7406\u670d\u52a1\u5668\u53ef\u4ee5\u63d0\u9ad8\u8bf7\u6c42\u7684\u6210\u529f\u7387\u548c\u901f\u5ea6\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b9a\u671f\u66f4\u6362\u4ee3\u7406IP<\/strong>\uff1a\u5c24\u5176\u662f\u5728\u8fdb\u884c\u5927\u91cf\u8bf7\u6c42\u65f6\uff0c\u5b9a\u671f\u66f4\u6362\u4ee3\u7406IP\u53ef\u4ee5\u6709\u6548\u907f\u514dIP\u88ab\u5c01\u7981\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5904\u7406\u4ee3\u7406\u5931\u8d25\u7684\u60c5\u51b5<\/strong>\uff1a\u5728\u7f16\u5199\u4ee3\u7801\u65f6\uff0c\u8981\u52a0\u5165\u5f02\u5e38\u5904\u7406\u673a\u5236\uff0c\u4ee5\u4fbf\u5728\u4ee3\u7406\u8bf7\u6c42\u5931\u8d25\u65f6\u8fdb\u884c\u91cd\u8bd5\u6216\u5207\u6362\u4ee3\u7406\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9075\u5faa\u6cd5\u5f8b\u6cd5\u89c4<\/strong>\uff1a\u4f7f\u7528\u4ee3\u7406IP\u65f6\uff0c\u5e94\u786e\u4fdd\u9075\u5faa\u76f8\u5173\u6cd5\u5f8b\u6cd5\u89c4\uff0c\u5c0a\u91cd\u4ed6\u4eba\u9690\u79c1\u548c\u6570\u636e\u5b89\u5168\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u4e0a\u8ff0\u65b9\u6cd5\u548c\u6700\u4f73\u5b9e\u8df5\uff0c\u4f60\u53ef\u4ee5\u5728Python\u4e2d\u7075\u6d3b\u5730\u8bbe\u7f6e\u548c\u4f7f\u7528\u4ee3\u7406IP\uff0c\u4ee5\u5e94\u5bf9\u4e0d\u540c\u7684\u7f51\u7edc\u8bf7\u6c42\u573a\u666f\u3002\u65e0\u8bba\u662f\u4f7f\u7528<code>requests<\/code>\u3001<code>urllib<\/code>\uff0c\u8fd8\u662f\u901a\u8fc7\u73af\u5883\u53d8\u91cf\u8bbe\u7f6e\u4ee3\u7406\uff0c\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\u53ef\u4ee5\u5e2e\u52a9\u4f60\u5728\u9879\u76ee\u4e2d\u9ad8\u6548\u5730\u7ba1\u7406\u7f51\u7edc\u8fde\u63a5\u548c\u6570\u636e\u4f20\u8f93\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u4f7f\u7528\u4ee3\u7406IP\u8fdb\u884c\u7f51\u7edc\u8bf7\u6c42\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u4f7f\u7528\u4ee3\u7406IP\u8fdb\u884c\u7f51\u7edc\u8bf7\u6c42\u901a\u5e38\u53ef\u4ee5\u901a\u8fc7<code>requests<\/code>\u5e93\u6765\u5b9e\u73b0\u3002\u4f60\u53ef\u4ee5\u5728\u8bf7\u6c42\u4e2d\u6307\u5b9a\u4ee3\u7406\u8bbe\u7f6e\u3002\u4f8b\u5982\uff0c\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u53ef\u4ee5\u914d\u7f6eHTTP\u548cHTTPS\u4ee3\u7406\uff1a<\/p>\n<pre><code class=\"language-python\">import requests\n\nproxies = {\n    &quot;http&quot;: &quot;http:\/\/your_proxy_ip:port&quot;,\n    &quot;https&quot;: &quot;https:\/\/your_proxy_ip:port&quot;,\n}\n\nresponse = requests.get(&quot;http:\/\/example.com&quot;, proxies=proxies)\nprint(response.text)\n<\/code><\/pre>\n<p>\u786e\u4fdd\u5c06<code>your_proxy_ip<\/code>\u548c<code>port<\/code>\u66ff\u6362\u4e3a\u5b9e\u9645\u7684\u4ee3\u7406IP\u5730\u5740\u548c\u7aef\u53e3\u53f7\u3002<\/p>\n<p><strong>\u4f7f\u7528\u4ee3\u7406IP\u65f6\u9700\u8981\u6ce8\u610f\u54ea\u4e9b\u4e8b\u9879\uff1f<\/strong><br \/>\u5728\u4f7f\u7528\u4ee3\u7406IP\u65f6\uff0c\u6709\u51e0\u4e2a\u5173\u952e\u70b9\u9700\u8981\u6ce8\u610f\u3002\u9996\u5148\uff0c\u786e\u4fdd\u6240\u4f7f\u7528\u7684\u4ee3\u7406IP\u662f\u53ef\u9760\u7684\uff0c\u907f\u514d\u4f7f\u7528\u4e0d\u5b89\u5168\u6216\u672a\u77e5\u6765\u6e90\u7684\u4ee3\u7406\uff0c\u8fd9\u53ef\u80fd\u5bfc\u81f4\u6570\u636e\u6cc4\u9732\u3002\u5176\u6b21\uff0c\u4e86\u89e3\u4ee3\u7406\u7684\u5e26\u5bbd\u548c\u5ef6\u8fdf\u60c5\u51b5\uff0c\u56e0\u4e3a\u8fd9\u4e9b\u56e0\u7d20\u53ef\u80fd\u4f1a\u5f71\u54cd\u4f60\u7684\u7f51\u7edc\u8bf7\u6c42\u901f\u5ea6\u3002\u6b64\u5916\uff0c\u786e\u4fdd\u9075\u5b88\u76ee\u6807\u7f51\u7ad9\u7684\u4f7f\u7528\u6761\u6b3e\uff0c\u4ee5\u514d\u56e0\u9891\u7e41\u8bf7\u6c42\u800c\u88ab\u5c01\u7981\u3002<\/p>\n<p><strong>\u5982\u4f55\u6d4b\u8bd5\u4ee3\u7406IP\u662f\u5426\u53ef\u7528\uff1f<\/strong><br \/>\u8981\u6d4b\u8bd5\u4ee3\u7406IP\u7684\u53ef\u7528\u6027\uff0c\u53ef\u4ee5\u7f16\u5199\u4e00\u4e2a\u7b80\u5355\u7684Python\u811a\u672c\u6765\u53d1\u9001\u8bf7\u6c42\u5e76\u68c0\u67e5\u54cd\u5e94\u3002\u4f8b\u5982\uff0c\u4f60\u53ef\u4ee5\u5c1d\u8bd5\u8bbf\u95ee\u4e00\u4e2a\u516c\u5f00\u7684API\u6216\u7f51\u9875\uff0c\u5e76\u67e5\u770b\u662f\u5426\u80fd\u591f\u6210\u529f\u8fd4\u56de\u6570\u636e\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u6d4b\u8bd5\u4ee3\u7406IP\u7684\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<pre><code class=\"language-python\">import requests\n\nproxy = &quot;http:\/\/your_proxy_ip:port&quot;\nproxies = {\n    &quot;http&quot;: proxy,\n    &quot;https&quot;: proxy,\n}\n\ntry:\n    response = requests.get(&quot;http:\/\/httpbin.org\/ip&quot;, proxies=proxies, timeout=5)\n    print(&quot;Proxy IP:&quot;, response.json())\nexcept requests.exceptions.RequestException as e:\n    print(&quot;Proxy is not working:&quot;, e)\n<\/code><\/pre>\n<p>\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0c\u4f60\u53ef\u4ee5\u5feb\u901f\u786e\u8ba4\u4ee3\u7406\u662f\u5426\u6b63\u5e38\u5de5\u4f5c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u4e2d\u8bbe\u7f6e\u4ee3\u7406IP\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528\u7b2c\u4e09\u65b9\u5e93\u3001\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\u3001\u76f4\u63a5\u5728\u8bf7\u6c42\u4e2d\u6307\u5b9a\u7b49\u65b9\u5f0f\u6765\u5b9e\u73b0\u3002\u4f7f\u7528\u7b2c\u4e09\u65b9\u5e93\u5982r [&hellip;]","protected":false},"author":3,"featured_media":992301,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/992294"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=992294"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/992294\/revisions"}],"predecessor-version":[{"id":992306,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/992294\/revisions\/992306"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/992301"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=992294"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=992294"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=992294"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}