{"id":932917,"date":"2024-12-26T18:06:58","date_gmt":"2024-12-26T10:06:58","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/932917.html"},"modified":"2024-12-26T18:07:01","modified_gmt":"2024-12-26T10:07:01","slug":"python%e5%a6%82%e4%bd%95%e7%88%ac%e5%b0%8f%e8%af%b4","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/932917.html","title":{"rendered":"python\u5982\u4f55\u722c\u5c0f\u8bf4"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25070541\/dcc103f7-7752-4a2c-92cf-0127c70f6df9.webp\" alt=\"python\u5982\u4f55\u722c\u5c0f\u8bf4\" \/><\/p>\n<p><p> <strong>\u8981\u4f7f\u7528Python\u722c\u53d6\u5c0f\u8bf4\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u5b9e\u73b0\uff1a\u9009\u62e9\u5408\u9002\u7684\u5de5\u5177\u5982requests\u548cBeautifulSoup\u3001\u89e3\u6790HTML\u7ed3\u6784\u3001\u5904\u7406\u5206\u9875\u548c\u9632\u6b62\u53cd\u722c\u866b\u63aa\u65bd\u3002<\/strong>\u5bf9\u4e8e\u521d\u5b66\u8005\uff0c\u5efa\u8bae\u4ece\u7b80\u5355\u7684\u722c\u866b\u5f00\u59cb\uff0c\u4e0d\u8981\u4e00\u5f00\u59cb\u5c31\u5c1d\u8bd5\u722c\u53d6\u5927\u578b\u7f51\u7ad9\uff0c\u56e0\u4e3a\u8fd9\u4e9b\u7f51\u7ad9\u901a\u5e38\u6709\u590d\u6742\u7684\u53cd\u722c\u866b\u673a\u5236\u3002\u9009\u62e9\u5408\u9002\u7684\u5de5\u5177\u662f\u5173\u952e\uff0c<code>requests<\/code>\u5e93\u7528\u4e8e\u53d1\u9001HTTP\u8bf7\u6c42\uff0c\u800c<code>BeautifulSoup<\/code>\u5219\u7528\u4e8e\u89e3\u6790\u548c\u63d0\u53d6HTML\u6570\u636e\u3002\u4e86\u89e3\u7f51\u7ad9\u7684HTML\u7ed3\u6784\u662f\u6210\u529f\u6293\u53d6\u5185\u5bb9\u7684\u57fa\u7840\uff0c\u901a\u5e38\u9700\u8981\u5728\u6d4f\u89c8\u5668\u4e2d\u901a\u8fc7\u5f00\u53d1\u8005\u5de5\u5177\u67e5\u770b\u7f51\u9875\u7684\u7ed3\u6784\u3002\u5904\u7406\u5206\u9875\u5219\u662f\u4e3a\u4e86\u6293\u53d6\u5b8c\u6574\u7684\u5c0f\u8bf4\u5185\u5bb9\uff0c\u56e0\u4e3a\u5927\u591a\u6570\u5c0f\u8bf4\u7f51\u7ad9\u4f1a\u5c06\u5c0f\u8bf4\u5206\u4e3a\u591a\u4e2a\u7ae0\u8282\u9875\u9762\u3002\u9632\u6b62\u53cd\u722c\u866b\u63aa\u65bd\u5219\u6d89\u53ca\u5230\u9075\u5faa\u7f51\u7ad9\u7684robots.txt\u6587\u4ef6\u3001\u8bbe\u7f6e\u5408\u9002\u7684\u8bf7\u6c42\u5934\u548c\u5ef6\u65f6\u3001\u4ee5\u53ca\u53ef\u80fd\u9700\u8981\u4f7f\u7528\u4ee3\u7406IP\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u9009\u62e9\u5408\u9002\u7684\u5de5\u5177<\/p>\n<\/p>\n<p><p>\u5728\u5f00\u59cb\u722c\u53d6\u5c0f\u8bf4\u4e4b\u524d\uff0c\u9009\u62e9\u5408\u9002\u7684\u5de5\u5177\u662f\u975e\u5e38\u91cd\u8981\u7684\u3002Python\u6709\u8bb8\u591a\u5f3a\u5927\u7684\u5e93\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u6784\u5efa\u722c\u866b\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>Requests\u5e93<\/strong><\/p>\n<\/p>\n<p><p><code>requests<\/code>\u5e93\u662f\u4e00\u4e2a\u975e\u5e38\u6d41\u884c\u7684HTTP\u5e93\uff0c\u53ef\u4ee5\u7528\u6765\u53d1\u9001HTTP\u8bf7\u6c42\u3002\u5bf9\u4e8e\u722c\u866b\u6765\u8bf4\uff0c<code>requests<\/code>\u5e93\u662f\u4e00\u4e2a\u975e\u5e38\u597d\u7684\u9009\u62e9\uff0c\u56e0\u4e3a\u5b83\u4f7f\u7528\u7b80\u5355\uff0c\u529f\u80fd\u5f3a\u5927\u3002<\/p>\n<\/p>\n<p><p>\u4f7f\u7528<code>requests<\/code>\u5e93\u53ef\u4ee5\u8f7b\u677e\u5730\u53d1\u9001GET\u8bf7\u6c42\u6765\u83b7\u53d6\u7f51\u9875\u5185\u5bb9\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import requests<\/p>\n<p>url = &quot;http:\/\/example.com&quot;<\/p>\n<p>response = requests.get(url)<\/p>\n<p>print(response.text)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u6bb5\u4ee3\u7801\u5c06\u83b7\u53d6<code>http:\/\/example.com<\/code>\u7684\u7f51\u9875\u5185\u5bb9\u5e76\u6253\u5370\u5230\u63a7\u5236\u53f0\u4e0a\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>BeautifulSoup\u5e93<\/strong><\/p>\n<\/p>\n<p><p><code>BeautifulSoup<\/code>\u5e93\u662f\u4e00\u4e2a\u7528\u4e8e\u89e3\u6790HTML\u548cXML\u6587\u6863\u7684\u5e93\uff0c\u5b83\u63d0\u4f9b\u4e86\u7b80\u5355\u7684API\u6765\u63d0\u53d6\u548c\u64cd\u4f5c\u7f51\u9875\u4e2d\u7684\u6570\u636e\u3002<\/p>\n<\/p>\n<p><p>\u4f7f\u7528<code>BeautifulSoup<\/code>\u53ef\u4ee5\u8f7b\u677e\u5730\u89e3\u6790HTML\u6587\u6863\u5e76\u63d0\u53d6\u6240\u9700\u7684\u6570\u636e\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from bs4 import BeautifulSoup<\/p>\n<p>html_content = &quot;&lt;html&gt;&lt;body&gt;&lt;h1&gt;Hello, World!&lt;\/h1&gt;&lt;\/body&gt;&lt;\/html&gt;&quot;<\/p>\n<p>soup = BeautifulSoup(html_content, &quot;html.parser&quot;)<\/p>\n<p>print(soup.h1.text)  # \u8f93\u51fa: Hello, World!<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><code>BeautifulSoup<\/code>\u652f\u6301\u591a\u79cd\u89e3\u6790\u5668\uff0c\u5176\u4e2d<code>html.parser<\/code>\u662fPython\u5185\u7f6e\u7684\u89e3\u6790\u5668\uff0c\u901f\u5ea6\u8f83\u6162\uff0c\u4f46\u4e0d\u9700\u8981\u5b89\u88c5\u5176\u4ed6\u4f9d\u8d56\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e8c\u3001\u89e3\u6790HTML\u7ed3\u6784<\/p>\n<\/p>\n<p><p>\u5728\u4f7f\u7528\u722c\u866b\u6293\u53d6\u6570\u636e\u4e4b\u524d\uff0c\u6211\u4eec\u9700\u8981\u4e86\u89e3\u76ee\u6807\u7f51\u9875\u7684HTML\u7ed3\u6784\u3002\u8fd9\u53ef\u4ee5\u901a\u8fc7\u6d4f\u89c8\u5668\u7684\u5f00\u53d1\u8005\u5de5\u5177\u6765\u5b9e\u73b0\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u67e5\u770bHTML\u7ed3\u6784<\/strong><\/p>\n<\/p>\n<p><p>\u4ee5Google Chrome\u4e3a\u4f8b\uff0c\u6253\u5f00\u6d4f\u89c8\u5668\u5e76\u8bbf\u95ee\u76ee\u6807\u7f51\u7ad9\u3002\u53f3\u952e\u70b9\u51fb\u9875\u9762\u4e2d\u7684\u67d0\u4e2a\u5143\u7d20\uff0c\u7136\u540e\u9009\u62e9\u201c\u68c0\u67e5\u201d\u6216\u201c\u68c0\u67e5\u5143\u7d20\u201d\u4ee5\u6253\u5f00\u5f00\u53d1\u8005\u5de5\u5177\u3002<\/p>\n<\/p>\n<p><p>\u5728\u5f00\u53d1\u8005\u5de5\u5177\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u7f51\u9875\u7684HTML\u7ed3\u6784\uff0c\u5e76\u627e\u5230\u6211\u4eec\u60f3\u8981\u6293\u53d6\u7684\u6570\u636e\u6240\u5728\u7684\u6807\u7b7e\u3002\u4f8b\u5982\uff0c\u4e00\u4e2a\u5c0f\u8bf4\u7ae0\u8282\u53ef\u80fd\u4f4d\u4e8e<code>&lt;div class=&quot;chapter-content&quot;&gt;<\/code>\u6807\u7b7e\u5185\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u63d0\u53d6\u6570\u636e<\/strong><\/p>\n<\/p>\n<p><p>\u4e00\u65e6\u4e86\u89e3\u4e86HTML\u7ed3\u6784\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u4f7f\u7528<code>BeautifulSoup<\/code>\u6765\u63d0\u53d6\u6240\u9700\u7684\u6570\u636e\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>from bs4 import BeautifulSoup<\/p>\n<p>url = &quot;http:\/\/example.com\/novel\/chapter1&quot;<\/p>\n<p>response = requests.get(url)<\/p>\n<p>soup = BeautifulSoup(response.text, &quot;html.parser&quot;)<\/p>\n<p>chapter_content = soup.find(&quot;div&quot;, class_=&quot;chapter-content&quot;)<\/p>\n<p>print(chapter_content.text)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u6bb5\u4ee3\u7801\u5c06\u63d0\u53d6\u5c0f\u8bf4\u7ae0\u8282\u7684\u5185\u5bb9\u5e76\u6253\u5370\u5230\u63a7\u5236\u53f0\u4e0a\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e09\u3001\u5904\u7406\u5206\u9875<\/p>\n<\/p>\n<p><p>\u5927\u591a\u6570\u5c0f\u8bf4\u7f51\u7ad9\u4f1a\u5c06\u5c0f\u8bf4\u5206\u4e3a\u591a\u4e2a\u7ae0\u8282\u9875\u9762\uff0c\u56e0\u6b64\u6211\u4eec\u9700\u8981\u5904\u7406\u5206\u9875\u4ee5\u6293\u53d6\u5b8c\u6574\u7684\u5c0f\u8bf4\u5185\u5bb9\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u627e\u5230\u4e0b\u4e00\u9875\u94fe\u63a5<\/strong><\/p>\n<\/p>\n<p><p>\u5728\u5f00\u53d1\u8005\u5de5\u5177\u4e2d\uff0c\u627e\u5230\u6307\u5411\u4e0b\u4e00\u7ae0\u8282\u7684\u94fe\u63a5\u3002\u901a\u5e38\uff0c\u8fd9\u4e2a\u94fe\u63a5\u4f1a\u4f4d\u4e8e\u4e00\u4e2a<code>&lt;a&gt;<\/code>\u6807\u7b7e\u4e2d\uff0c\u5e76\u5305\u542b\u7c7b\u4f3c\u201c\u4e0b\u4e00\u7ae0\u201d\u6216\u201c\u4e0b\u4e00\u9875\u201d\u7684\u6587\u5b57\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5faa\u73af\u6293\u53d6\u6240\u6709\u7ae0\u8282<\/strong><\/p>\n<\/p>\n<p><p>\u4f7f\u7528\u4e00\u4e2a\u5faa\u73af\u6765\u6293\u53d6\u6240\u6709\u7ae0\u8282\u7684\u5185\u5bb9\u3002\u5728\u6bcf\u6b21\u5faa\u73af\u4e2d\uff0c\u83b7\u53d6\u5f53\u524d\u7ae0\u8282\u7684\u5185\u5bb9\u5e76\u627e\u5230\u6307\u5411\u4e0b\u4e00\u7ae0\u8282\u7684\u94fe\u63a5\uff0c\u7136\u540e\u7ee7\u7eed\u6293\u53d6\u4e0b\u4e00\u7ae0\u8282\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import requests<\/p>\n<p>from bs4 import BeautifulSoup<\/p>\n<p>base_url = &quot;http:\/\/example.com\/novel\/&quot;<\/p>\n<p>next_page = &quot;chapter1&quot;<\/p>\n<p>while next_page:<\/p>\n<p>    url = base_url + next_page<\/p>\n<p>    response = requests.get(url)<\/p>\n<p>    soup = BeautifulSoup(response.text, &quot;html.parser&quot;)<\/p>\n<p>    chapter_content = soup.find(&quot;div&quot;, class_=&quot;chapter-content&quot;)<\/p>\n<p>    print(chapter_content.text)<\/p>\n<p>    next_link = soup.find(&quot;a&quot;, text=&quot;\u4e0b\u4e00\u7ae0&quot;)<\/p>\n<p>    next_page = next_link[&quot;href&quot;] if next_link else None<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u6bb5\u4ee3\u7801\u5c06\u6293\u53d6\u6240\u6709\u7ae0\u8282\u7684\u5185\u5bb9\uff0c\u5e76\u5728\u63a7\u5236\u53f0\u4e0a\u6253\u5370\u51fa\u6765\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u56db\u3001\u9632\u6b62\u53cd\u722c\u866b\u63aa\u65bd<\/p>\n<\/p>\n<p><p>\u8bb8\u591a\u7f51\u7ad9\u4f1a\u91c7\u53d6\u53cd\u722c\u866b\u63aa\u65bd\u6765\u9632\u6b62\u81ea\u52a8\u5316\u7a0b\u5e8f\u6293\u53d6\u5185\u5bb9\u3002\u4e3a\u4e86\u907f\u514d\u88ab\u5c01\u7981\uff0c\u6211\u4eec\u9700\u8981\u9075\u5faa\u4e00\u4e9b\u6700\u4f73\u5b9e\u8df5\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u9075\u5faarobots.txt\u6587\u4ef6<\/strong><\/p>\n<\/p>\n<p><p>\u5728\u6293\u53d6\u7f51\u7ad9\u4e4b\u524d\uff0c\u67e5\u770b\u7f51\u7ad9\u7684<code>robots.txt<\/code>\u6587\u4ef6\uff08\u901a\u5e38\u4f4d\u4e8e<code>http:\/\/example.com\/robots.txt<\/code>\uff09\u4ee5\u4e86\u89e3\u7f51\u7ad9\u5141\u8bb8\u548c\u4e0d\u5141\u8bb8\u6293\u53d6\u7684\u90e8\u5206\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8bbe\u7f6e\u5408\u9002\u7684\u8bf7\u6c42\u5934<\/strong><\/p>\n<\/p>\n<p><p>\u5728\u53d1\u9001\u8bf7\u6c42\u65f6\uff0c\u8bbe\u7f6e\u5408\u9002\u7684\u8bf7\u6c42\u5934\u4ee5\u6a21\u62df\u771f\u5b9e\u7528\u6237\u7684\u8bf7\u6c42\u3002\u4f8b\u5982\uff0c\u8bbe\u7f6e<code>User-Agent<\/code>\u5934\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">headers = {<\/p>\n<p>    &quot;User-Agent&quot;: &quot;Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/58.0.3029.110 Safari\/537.3&quot;<\/p>\n<p>}<\/p>\n<p>response = requests.get(url, headers=headers)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6dfb\u52a0\u5ef6\u65f6<\/strong><\/p>\n<\/p>\n<p><p>\u5728\u6bcf\u6b21\u8bf7\u6c42\u4e4b\u95f4\u6dfb\u52a0\u5ef6\u65f6\uff0c\u4ee5\u907f\u514d\u8fc7\u4e8e\u9891\u7e41\u7684\u8bf7\u6c42\u5bfc\u81f4\u88ab\u5c01\u7981\u3002\u53ef\u4ee5\u4f7f\u7528<code>time.sleep()<\/code>\u51fd\u6570\u6765\u5b9e\u73b0\u5ef6\u65f6\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import time<\/p>\n<p>time.sleep(2)  # \u5ef6\u65f62\u79d2<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528\u4ee3\u7406IP<\/strong><\/p>\n<\/p>\n<p><p>\u5982\u679c\u7f51\u7ad9\u9650\u5236\u4e86\u67d0\u4e2aIP\u5730\u5740\u7684\u8bbf\u95ee\u9891\u7387\uff0c\u53ef\u4ee5\u8003\u8651\u4f7f\u7528\u4ee3\u7406IP\u6765\u66f4\u6362IP\u5730\u5740\u3002Python\u7684<code>requests<\/code>\u5e93\u652f\u6301\u901a\u8fc7\u4ee3\u7406\u53d1\u9001\u8bf7\u6c42\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">proxies = {<\/p>\n<p>    &quot;http&quot;: &quot;http:\/\/10.10.1.10:3128&quot;,<\/p>\n<p>    &quot;https&quot;: &quot;https:\/\/10.10.1.10:1080&quot;,<\/p>\n<p>}<\/p>\n<p>response = requests.get(url, headers=headers, proxies=proxies)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u9075\u5faa\u4ee5\u4e0a\u6b65\u9aa4\u548c\u6700\u4f73\u5b9e\u8df5\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528Python\u6210\u529f\u5730\u722c\u53d6\u5c0f\u8bf4\u5185\u5bb9\u3002\u7136\u800c\uff0c\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u722c\u866b\u5e94\u4ec5\u7528\u4e8e\u5408\u6cd5\u548c\u9053\u5fb7\u7684\u7528\u9014\uff0c\u5c0a\u91cd\u76ee\u6807\u7f51\u7ad9\u7684\u7248\u6743\u548c\u4f7f\u7528\u6761\u6b3e\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u9009\u62e9\u5408\u9002\u7684Python\u5e93\u6765\u722c\u53d6\u5c0f\u8bf4\uff1f<\/strong><br \/>\u5728\u4f7f\u7528Python\u722c\u53d6\u5c0f\u8bf4\u65f6\uff0c\u9009\u62e9\u5408\u9002\u7684\u5e93\u81f3\u5173\u91cd\u8981\u3002\u5e38\u7528\u7684\u5e93\u5305\u62ecRequests\u7528\u4e8e\u53d1\u9001HTTP\u8bf7\u6c42\uff0cBeautifulSoup\u7528\u4e8e\u89e3\u6790HTML\u6587\u6863\uff0cScrapy\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u722c\u866b\u6846\u67b6\uff0c\u9002\u5408\u5904\u7406\u590d\u6742\u7684\u7f51\u7ad9\u7ed3\u6784\u3002\u6b64\u5916\uff0clxml\u548cSelenium\u4e5f\u53ef\u4ee5\u7528\u4e8e\u5904\u7406\u52a8\u6001\u5185\u5bb9\u548c\u590d\u6742\u7684\u7f51\u9875\u7ed3\u6784\u3002\u6839\u636e\u5177\u4f53\u7684\u9700\u6c42\u548c\u7f51\u7ad9\u7684\u590d\u6742\u7a0b\u5ea6\uff0c\u9009\u62e9\u6700\u9002\u5408\u7684\u5e93\u5c06\u6709\u52a9\u4e8e\u63d0\u9ad8\u722c\u53d6\u6548\u7387\u3002<\/p>\n<p><strong>\u722c\u53d6\u5c0f\u8bf4\u65f6\u9700\u8981\u6ce8\u610f\u54ea\u4e9b\u6cd5\u5f8b\u548c\u9053\u5fb7\u95ee\u9898\uff1f<\/strong><br \/>\u5728\u8fdb\u884c\u5c0f\u8bf4\u722c\u53d6\u65f6\uff0c\u9075\u5faa\u6cd5\u5f8b\u6cd5\u89c4\u548c\u9053\u5fb7\u89c4\u8303\u975e\u5e38\u91cd\u8981\u3002\u9996\u5148\uff0c\u5e94\u786e\u4fdd\u9075\u5b88\u7f51\u7ad9\u7684robots.txt\u6587\u4ef6\u4e2d\u7684\u722c\u53d6\u89c4\u5219\uff0c\u907f\u514d\u5bf9\u7f51\u7ad9\u9020\u6210\u8d1f\u62c5\u3002\u6b64\u5916\uff0c\u722c\u53d6\u7684\u5185\u5bb9\u5e94\u4ec5\u7528\u4e8e\u4e2a\u4eba\u5b66\u4e60\u548c\u7814\u7a76\u76ee\u7684\uff0c\u800c\u4e0d\u662f\u7528\u4e8e\u5546\u4e1a\u7528\u9014\u3002\u5c0a\u91cd\u7248\u6743\u548c\u4f5c\u8005\u7684\u6743\u76ca\uff0c\u907f\u514d\u4fb5\u72af\u77e5\u8bc6\u4ea7\u6743\u662f\u6bcf\u4e2a\u722c\u866b\u5f00\u53d1\u8005\u5e94\u5f53\u9075\u5faa\u7684\u539f\u5219\u3002<\/p>\n<p><strong>\u5982\u4f55\u5904\u7406\u722c\u53d6\u8fc7\u7a0b\u4e2d\u9047\u5230\u7684\u53cd\u722c\u866b\u673a\u5236\uff1f<\/strong><br \/>\u8bb8\u591a\u7f51\u7ad9\u4f1a\u91c7\u53d6\u53cd\u722c\u866b\u63aa\u65bd\u6765\u4fdd\u62a4\u5176\u5185\u5bb9\u3002\u9762\u5bf9\u8fd9\u4e9b\u673a\u5236\uff0c\u53ef\u4ee5\u91c7\u53d6\u591a\u79cd\u5e94\u5bf9\u7b56\u7565\u3002\u4f8b\u5982\uff0c\u4f7f\u7528\u968f\u673a\u7684User-Agent\u6765\u6a21\u62df\u4e0d\u540c\u7684\u6d4f\u89c8\u5668\u8bf7\u6c42\uff0c\u8bbe\u7f6e\u8bf7\u6c42\u95f4\u9694\u65f6\u95f4\u4ee5\u51cf\u5c11\u9891\u7387\uff0c\u4f7f\u7528\u4ee3\u7406IP\u6765\u9690\u85cf\u771f\u5b9eIP\u5730\u5740\u3002\u6b64\u5916\uff0c\u5b66\u4e60\u4f7f\u7528\u52a8\u6001\u722c\u866b\u5de5\u5177\uff0c\u6bd4\u5982Selenium\uff0c\u53ef\u4ee5\u5e2e\u52a9\u5904\u7406JavaScript\u751f\u6210\u7684\u5185\u5bb9\u3002\u4e86\u89e3\u5e76\u5e94\u5bf9\u8fd9\u4e9b\u53cd\u722c\u866b\u673a\u5236\u5bf9\u4e8e\u6210\u529f\u722c\u53d6\u5c0f\u8bf4\u81f3\u5173\u91cd\u8981\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u8981\u4f7f\u7528Python\u722c\u53d6\u5c0f\u8bf4\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u5b9e\u73b0\uff1a\u9009\u62e9\u5408\u9002\u7684\u5de5\u5177\u5982requests\u548cBeautifulSoup [&hellip;]","protected":false},"author":3,"featured_media":932918,"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\/932917"}],"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=932917"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/932917\/revisions"}],"predecessor-version":[{"id":932919,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/932917\/revisions\/932919"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/932918"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=932917"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=932917"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=932917"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}