{"id":1068889,"date":"2024-12-31T16:47:11","date_gmt":"2024-12-31T08:47:11","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1068889.html"},"modified":"2024-12-31T16:47:13","modified_gmt":"2024-12-31T08:47:13","slug":"python%e5%a6%82%e4%bd%95%e5%b0%86%e7%bd%91%e9%a1%b5%e4%bf%a1%e6%81%af%e4%bf%9d%e5%ad%98%e5%88%b0%e6%96%87%e6%9c%ac","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1068889.html","title":{"rendered":"python\u5982\u4f55\u5c06\u7f51\u9875\u4fe1\u606f\u4fdd\u5b58\u5230\u6587\u672c"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2024\/12\/2962b582-9cfa-422a-9dcf-45d4b301bd4a.webp?x-oss-process=image\/auto-orient,1\/format,webp\" alt=\"python\u5982\u4f55\u5c06\u7f51\u9875\u4fe1\u606f\u4fdd\u5b58\u5230\u6587\u672c\" \/><\/p>\n<p><p> <strong>Python\u5982\u4f55\u5c06\u7f51\u9875\u4fe1\u606f\u4fdd\u5b58\u5230\u6587\u672c<\/strong><\/p>\n<\/p>\n<p><p>\u5728Python\u4e2d\uff0c\u5c06\u7f51\u9875\u4fe1\u606f\u4fdd\u5b58\u5230\u6587\u672c\u7684\u6b65\u9aa4\u5305\u62ec\uff1a\u53d1\u9001HTTP\u8bf7\u6c42\u3001\u89e3\u6790\u7f51\u9875\u5185\u5bb9\u3001\u63d0\u53d6\u6240\u9700\u6570\u636e\u3001\u5c06\u6570\u636e\u5199\u5165\u6587\u672c\u6587\u4ef6\u3002<strong>\u53d1\u9001HTTP\u8bf7\u6c42\u3001\u89e3\u6790\u7f51\u9875\u5185\u5bb9\u3001\u63d0\u53d6\u6240\u9700\u6570\u636e\u3001\u5c06\u6570\u636e\u5199\u5165\u6587\u672c\u6587\u4ef6<\/strong>\u3002\u5176\u4e2d\uff0c\u53d1\u9001HTTP\u8bf7\u6c42\u662f\u83b7\u53d6\u7f51\u9875\u5185\u5bb9\u7684\u7b2c\u4e00\u6b65\uff0c\u89e3\u6790\u7f51\u9875\u5185\u5bb9\u53ef\u4ee5\u4f7f\u7528BeautifulSoup\u5e93\uff0c\u63d0\u53d6\u6570\u636e\u53ef\u4ee5\u5229\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u6216\u5176\u4ed6\u5de5\u5177\uff0c\u6700\u540e\u5c06\u6570\u636e\u5199\u5165\u6587\u672c\u6587\u4ef6\u4fdd\u5b58\u3002\u4e0b\u9762\u8be6\u7ec6\u4ecb\u7ecd\u8fd9\u4e9b\u6b65\u9aa4\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u53d1\u9001HTTP\u8bf7\u6c42<\/h3>\n<\/p>\n<p><p>\u53d1\u9001HTTP\u8bf7\u6c42\u662f\u83b7\u53d6\u7f51\u9875\u5185\u5bb9\u7684\u7b2c\u4e00\u6b65\u3002Python\u4e2d\u5e38\u7528\u7684\u5e93\u662f<code>requests<\/code>\u3002\u901a\u8fc7<code>requests<\/code>\u5e93\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u53d1\u9001GET\u3001POST\u7b49HTTP\u8bf7\u6c42\uff0c\u5e76\u83b7\u53d6\u7f51\u9875\u5185\u5bb9\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import requests<\/p>\n<h2><strong>\u53d1\u9001GET\u8bf7\u6c42<\/strong><\/h2>\n<p>response = requests.get(&#39;https:\/\/example.com&#39;)<\/p>\n<h2><strong>\u68c0\u67e5\u8bf7\u6c42\u662f\u5426\u6210\u529f<\/strong><\/h2>\n<p>if response.status_code == 200:<\/p>\n<p>    print(&quot;\u8bf7\u6c42\u6210\u529f&quot;)<\/p>\n<p>    content = response.text  # \u83b7\u53d6\u7f51\u9875\u5185\u5bb9<\/p>\n<p>else:<\/p>\n<p>    print(&quot;\u8bf7\u6c42\u5931\u8d25&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e8c\u3001\u89e3\u6790\u7f51\u9875\u5185\u5bb9<\/h3>\n<\/p>\n<p><p>\u83b7\u53d6\u7f51\u9875\u5185\u5bb9\u540e\uff0c\u9700\u8981\u89e3\u6790HTML\u7ed3\u6784\u4ee5\u63d0\u53d6\u6240\u9700\u6570\u636e\u3002<code>BeautifulSoup<\/code>\u662f\u4e00\u4e2a\u5e7f\u6cdb\u4f7f\u7528\u7684\u89e3\u6790\u5e93\uff0c\u5b83\u53ef\u4ee5\u8f7b\u677e\u5730\u89e3\u6790HTML\u548cXML\u6587\u6863\uff0c\u5e76\u63d0\u53d6\u6240\u9700\u6570\u636e\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from bs4 import BeautifulSoup<\/p>\n<h2><strong>\u4f7f\u7528BeautifulSoup\u89e3\u6790HTML\u5185\u5bb9<\/strong><\/h2>\n<p>soup = BeautifulSoup(content, &#39;html.parser&#39;)<\/p>\n<h2><strong>\u67e5\u627e\u6240\u6709\u7684\u6bb5\u843d\u6807\u7b7e&lt;p&gt;<\/strong><\/h2>\n<p>paragraphs = soup.find_all(&#39;p&#39;)<\/p>\n<h2><strong>\u6253\u5370\u6240\u6709\u6bb5\u843d\u7684\u6587\u672c\u5185\u5bb9<\/strong><\/h2>\n<p>for p in paragraphs:<\/p>\n<p>    print(p.get_text())<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e09\u3001\u63d0\u53d6\u6240\u9700\u6570\u636e<\/h3>\n<\/p>\n<p><p>\u5728\u89e3\u6790\u7f51\u9875\u5185\u5bb9\u540e\uff0c\u9700\u8981\u63d0\u53d6\u7279\u5b9a\u7684\u6570\u636e\u3002\u53ef\u4ee5\u4f7f\u7528<code>BeautifulSoup<\/code>\u7684\u5404\u79cd\u67e5\u627e\u65b9\u6cd5\uff0c\u5982<code>find<\/code>\u3001<code>find_all<\/code>\u3001<code>select<\/code>\u7b49\uff0c\u8fd8\u53ef\u4ee5\u7ed3\u5408\u6b63\u5219\u8868\u8fbe\u5f0f\u8fdb\u884c\u6570\u636e\u63d0\u53d6\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import re<\/p>\n<h2><strong>\u67e5\u627e\u6240\u6709\u5305\u542b\u7279\u5b9a\u5173\u952e\u8bcd\u7684\u6bb5\u843d<\/strong><\/h2>\n<p>keyword = &quot;Python&quot;<\/p>\n<p>matching_paragraphs = soup.find_all(&#39;p&#39;, text=re.compile(keyword))<\/p>\n<h2><strong>\u6253\u5370\u5339\u914d\u5230\u7684\u6bb5\u843d\u6587\u672c\u5185\u5bb9<\/strong><\/h2>\n<p>for p in matching_paragraphs:<\/p>\n<p>    print(p.get_text())<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u56db\u3001\u5c06\u6570\u636e\u5199\u5165\u6587\u672c\u6587\u4ef6<\/h3>\n<\/p>\n<p><p>\u63d0\u53d6\u6570\u636e\u540e\uff0c\u53ef\u4ee5\u5c06\u5176\u5199\u5165\u6587\u672c\u6587\u4ef6\u4fdd\u5b58\u3002\u4f7f\u7528Python\u7684\u5185\u7f6e<code>open<\/code>\u51fd\u6570\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u5199\u5165\u6587\u672c\u6587\u4ef6\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u6253\u5f00\u6587\u4ef6\u4ee5\u5199\u5165\u6a21\u5f0f<\/p>\n<p>with open(&#39;output.txt&#39;, &#39;w&#39;, encoding=&#39;utf-8&#39;) as file:<\/p>\n<p>    # \u5199\u5165\u6bcf\u4e2a\u6bb5\u843d\u7684\u6587\u672c\u5185\u5bb9<\/p>\n<p>    for p in matching_paragraphs:<\/p>\n<p>        file.write(p.get_text() + &#39;\\n&#39;)<\/p>\n<p>print(&quot;\u6570\u636e\u5df2\u4fdd\u5b58\u5230output.txt&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e94\u3001\u5b8c\u6574\u793a\u4f8b<\/h3>\n<\/p>\n<p><p>\u5c06\u4ee5\u4e0a\u6b65\u9aa4\u6574\u5408\u6210\u4e00\u4e2a\u5b8c\u6574\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>import re<\/p>\n<h2><strong>\u53d1\u9001GET\u8bf7\u6c42\u83b7\u53d6\u7f51\u9875\u5185\u5bb9<\/strong><\/h2>\n<p>response = requests.get(&#39;https:\/\/example.com&#39;)<\/p>\n<p>if response.status_code == 200:<\/p>\n<p>    content = response.text<\/p>\n<p>else:<\/p>\n<p>    print(&quot;\u8bf7\u6c42\u5931\u8d25&quot;)<\/p>\n<p>    exit()<\/p>\n<h2><strong>\u4f7f\u7528BeautifulSoup\u89e3\u6790HTML\u5185\u5bb9<\/strong><\/h2>\n<p>soup = BeautifulSoup(content, &#39;html.parser&#39;)<\/p>\n<h2><strong>\u67e5\u627e\u6240\u6709\u5305\u542b\u7279\u5b9a\u5173\u952e\u8bcd\u7684\u6bb5\u843d<\/strong><\/h2>\n<p>keyword = &quot;Python&quot;<\/p>\n<p>matching_paragraphs = soup.find_all(&#39;p&#39;, text=re.compile(keyword))<\/p>\n<h2><strong>\u6253\u5f00\u6587\u4ef6\u4ee5\u5199\u5165\u6a21\u5f0f<\/strong><\/h2>\n<p>with open(&#39;output.txt&#39;, &#39;w&#39;, encoding=&#39;utf-8&#39;) as file:<\/p>\n<p>    # \u5199\u5165\u6bcf\u4e2a\u6bb5\u843d\u7684\u6587\u672c\u5185\u5bb9<\/p>\n<p>    for p in matching_paragraphs:<\/p>\n<p>        file.write(p.get_text() + &#39;\\n&#39;)<\/p>\n<p>print(&quot;\u6570\u636e\u5df2\u4fdd\u5b58\u5230output.txt&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u516d\u3001\u5904\u7406\u590d\u6742\u7f51\u9875<\/h3>\n<\/p>\n<p><p>\u5bf9\u4e8e\u4e00\u4e9b\u590d\u6742\u7684\u7f51\u9875\uff0c\u53ef\u80fd\u9700\u8981\u5904\u7406JavaScript\u751f\u6210\u7684\u5185\u5bb9\uff0c\u6216\u8005\u9700\u8981\u767b\u5f55\u624d\u80fd\u8bbf\u95ee\u7684\u6570\u636e\u3002\u6b64\u65f6\u53ef\u4ee5\u4f7f\u7528<code>Selenium<\/code>\u5e93\u6765\u6a21\u62df\u6d4f\u89c8\u5668\u64cd\u4f5c\uff0c\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from selenium import webdriver<\/p>\n<h2><strong>\u521b\u5efaChrome\u6d4f\u89c8\u5668\u5b9e\u4f8b<\/strong><\/h2>\n<p>driver = webdriver.Chrome()<\/p>\n<h2><strong>\u6253\u5f00\u76ee\u6807\u7f51\u9875<\/strong><\/h2>\n<p>driver.get(&#39;https:\/\/example.com&#39;)<\/p>\n<h2><strong>\u7b49\u5f85\u9875\u9762\u52a0\u8f7d\u5b8c\u6210<\/strong><\/h2>\n<p>driver.implicitly_w<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>t(10)<\/p>\n<h2><strong>\u83b7\u53d6\u9875\u9762\u5185\u5bb9<\/strong><\/h2>\n<p>content = driver.page_source<\/p>\n<h2><strong>\u4f7f\u7528BeautifulSoup\u89e3\u6790HTML\u5185\u5bb9<\/strong><\/h2>\n<p>soup = BeautifulSoup(content, &#39;html.parser&#39;)<\/p>\n<h2><strong>\u67e5\u627e\u6240\u6709\u5305\u542b\u7279\u5b9a\u5173\u952e\u8bcd\u7684\u6bb5\u843d<\/strong><\/h2>\n<p>keyword = &quot;Python&quot;<\/p>\n<p>matching_paragraphs = soup.find_all(&#39;p&#39;, text=re.compile(keyword))<\/p>\n<h2><strong>\u6253\u5f00\u6587\u4ef6\u4ee5\u5199\u5165\u6a21\u5f0f<\/strong><\/h2>\n<p>with open(&#39;output.txt&#39;, &#39;w&#39;, encoding=&#39;utf-8&#39;) as file:<\/p>\n<p>    # \u5199\u5165\u6bcf\u4e2a\u6bb5\u843d\u7684\u6587\u672c\u5185\u5bb9<\/p>\n<p>    for p in matching_paragraphs:<\/p>\n<p>        file.write(p.get_text() + &#39;\\n&#39;)<\/p>\n<p>print(&quot;\u6570\u636e\u5df2\u4fdd\u5b58\u5230output.txt&quot;)<\/p>\n<h2><strong>\u5173\u95ed\u6d4f\u89c8\u5668<\/strong><\/h2>\n<p>driver.quit()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e03\u3001\u5904\u7406\u53cd\u722c\u866b\u673a\u5236<\/h3>\n<\/p>\n<p><p>\u6709\u4e9b\u7f51\u7ad9\u4f1a\u4f7f\u7528\u53cd\u722c\u866b\u673a\u5236\u6765\u963b\u6b62\u722c\u866b\u83b7\u53d6\u6570\u636e\u3002\u5e38\u89c1\u7684\u53cd\u722c\u866b\u673a\u5236\u5305\u62ec\uff1aIP\u5c01\u7981\u3001\u9a8c\u8bc1\u7801\u3001\u52a8\u6001\u5185\u5bb9\u52a0\u8f7d\u7b49\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5\u6765\u7ed5\u8fc7\u53cd\u722c\u866b\u673a\u5236\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4f7f\u7528\u4ee3\u7406IP<\/strong>\uff1a\u901a\u8fc7\u4f7f\u7528\u4ee3\u7406IP\uff0c\u53ef\u4ee5\u907f\u514dIP\u5c01\u7981\u3002\u53ef\u4ee5\u4f7f\u7528<code>requests<\/code>\u5e93\u7684<code>proxies<\/code>\u53c2\u6570\u6765\u8bbe\u7f6e\u4ee3\u7406IP\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">proxies = {<\/p>\n<p>    &#39;http&#39;: &#39;http:\/\/your_proxy_ip:port&#39;,<\/p>\n<p>    &#39;https&#39;: &#39;http:\/\/your_proxy_ip:port&#39;,<\/p>\n<p>}<\/p>\n<p>response = requests.get(&#39;https:\/\/example.com&#39;, proxies=proxies)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6a21\u62df\u6d4f\u89c8\u5668<\/strong>\uff1a\u901a\u8fc7\u8bbe\u7f6e\u8bf7\u6c42\u5934\u4e2d\u7684User-Agent\u7b49\u53c2\u6570\uff0c\u53ef\u4ee5\u6a21\u62df\u6d4f\u89c8\u5668\u8bf7\u6c42\uff0c\u907f\u514d\u88ab\u8bc6\u522b\u4e3a\u722c\u866b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">headers = {<\/p>\n<p>    &#39;User-Agent&#39;: &#39;Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/58.0.3029.110 Safari\/537.3&#39;<\/p>\n<p>}<\/p>\n<p>response = requests.get(&#39;https:\/\/example.com&#39;, headers=headers)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5904\u7406\u9a8c\u8bc1\u7801<\/strong>\uff1a\u5bf9\u4e8e\u9700\u8981\u9a8c\u8bc1\u7801\u7684\u7f51\u7ad9\uff0c\u53ef\u4ee5\u4f7f\u7528\u56fe\u50cf\u8bc6\u522b\u6280\u672f\u6216\u624b\u52a8\u8f93\u5165\u9a8c\u8bc1\u7801\u6765\u7ed5\u8fc7\u9a8c\u8bc1\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5ef6\u8fdf\u8bf7\u6c42<\/strong>\uff1a\u901a\u8fc7\u8bbe\u7f6e\u8bf7\u6c42\u95f4\u9694\uff0c\u907f\u514d\u8fc7\u4e8e\u9891\u7e41\u7684\u8bf7\u6c42\u5bfc\u81f4\u88ab\u5c01\u7981\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import time<\/p>\n<p>time.sleep(2)  # \u5ef6\u8fdf2\u79d2<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u516b\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u901a\u8fc7\u4f7f\u7528Python\u7684<code>requests<\/code>\u3001<code>BeautifulSoup<\/code>\u3001<code>Selenium<\/code>\u7b49\u5e93\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u5c06\u7f51\u9875\u4fe1\u606f\u4fdd\u5b58\u5230\u6587\u672c\u6587\u4ef6\u3002\u5728\u5b9e\u9645\u64cd\u4f5c\u4e2d\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u5404\u79cd\u590d\u6742\u60c5\u51b5\u548c\u53cd\u722c\u866b\u673a\u5236\uff0c\u9700\u8981\u6839\u636e\u5177\u4f53\u60c5\u51b5\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\u6765\u5904\u7406\u3002\u5e0c\u671b\u4ee5\u4e0a\u5185\u5bb9\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u4f7f\u7528Python\u5c06\u7f51\u9875\u5185\u5bb9\u63d0\u53d6\u5e76\u4fdd\u5b58\u4e3a\u6587\u672c\u6587\u4ef6\uff1f<\/strong><br \/>\u8981\u63d0\u53d6\u7f51\u9875\u5185\u5bb9\u5e76\u4fdd\u5b58\u4e3a\u6587\u672c\u6587\u4ef6\uff0c\u53ef\u4ee5\u4f7f\u7528Python\u7684<code>requests<\/code>\u5e93\u83b7\u53d6\u7f51\u9875\u5185\u5bb9\uff0c\u7ed3\u5408<code>BeautifulSoup<\/code>\u5e93\u89e3\u6790HTML\u3002\u83b7\u53d6\u6570\u636e\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528\u5185\u7f6e\u7684\u6587\u4ef6\u64cd\u4f5c\u5c06\u5185\u5bb9\u5199\u5165\u6587\u672c\u6587\u4ef6\u3002\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"language-python\">import requests\nfrom bs4 import BeautifulSoup\n\nurl = &#39;https:\/\/example.com&#39;\nresponse = requests.get(url)\nsoup = BeautifulSoup(response.text, &#39;html.parser&#39;)\n\n# \u63d0\u53d6\u7f51\u9875\u4e2d\u7684\u7279\u5b9a\u4fe1\u606f\uff0c\u4f8b\u5982\u6807\u9898\ntitle = soup.title.string\n\n# \u5c06\u4fe1\u606f\u4fdd\u5b58\u5230\u6587\u672c\u6587\u4ef6\nwith open(&#39;web_content.txt&#39;, &#39;w&#39;, encoding=&#39;utf-8&#39;) as file:\n    file.write(title)\n<\/code><\/pre>\n<p><strong>\u5728\u4f7f\u7528Python\u6293\u53d6\u7f51\u9875\u4fe1\u606f\u65f6\uff0c\u6709\u54ea\u4e9b\u6ce8\u610f\u4e8b\u9879\uff1f<\/strong><br \/>\u5728\u6293\u53d6\u7f51\u9875\u65f6\u9700\u9075\u5faa\u7f51\u7ad9\u7684<code>robots.txt<\/code>\u6587\u4ef6\u89c4\u5b9a\uff0c\u786e\u4fdd\u60a8\u7684\u884c\u4e3a\u7b26\u5408\u7f51\u7ad9\u7684\u4f7f\u7528\u6761\u6b3e\u3002\u6b64\u5916\uff0c\u8bf7\u6ce8\u610f\u6293\u53d6\u901f\u5ea6\uff0c\u907f\u514d\u5bf9\u670d\u52a1\u5668\u9020\u6210\u8fc7\u5927\u538b\u529b\uff0c\u5efa\u8bae\u4f7f\u7528\u9002\u5f53\u7684\u5ef6\u65f6\u3002\u540c\u65f6\uff0c\u5904\u7406\u5f02\u5e38\u60c5\u51b5\uff0c\u786e\u4fdd\u7a0b\u5e8f\u7684\u7a33\u5b9a\u6027\u3002<\/p>\n<p><strong>\u53ef\u4ee5\u4f7f\u7528\u54ea\u4e9bPython\u5e93\u6765\u5904\u7406\u7f51\u9875\u6293\u53d6\u548c\u6587\u672c\u4fdd\u5b58\uff1f<\/strong><br \/>\u5e38\u7528\u7684Python\u5e93\u5305\u62ec<code>requests<\/code>\u7528\u4e8e\u53d1\u9001HTTP\u8bf7\u6c42\uff0c<code>BeautifulSoup<\/code>\u7528\u4e8e\u89e3\u6790HTML\u6587\u6863\uff0c<code>lxml<\/code>\u53ef\u4ee5\u4f5c\u4e3a\u89e3\u6790\u5668\u4ee5\u63d0\u9ad8\u6027\u80fd\uff0c\u6b64\u5916<code>pandas<\/code>\u4e5f\u9002\u5408\u5904\u7406\u548c\u4fdd\u5b58\u7ed3\u6784\u5316\u6570\u636e\u3002\u5bf9\u4e8e\u5927\u89c4\u6a21\u6570\u636e\u6293\u53d6\uff0c\u53ef\u4ee5\u8003\u8651\u4f7f\u7528<code>Scrapy<\/code>\u6846\u67b6\uff0c\u80fd\u591f\u66f4\u9ad8\u6548\u5730\u7ba1\u7406\u722c\u866b\u4efb\u52a1\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Python\u5982\u4f55\u5c06\u7f51\u9875\u4fe1\u606f\u4fdd\u5b58\u5230\u6587\u672c \u5728Python\u4e2d\uff0c\u5c06\u7f51\u9875\u4fe1\u606f\u4fdd\u5b58\u5230\u6587\u672c\u7684\u6b65\u9aa4\u5305\u62ec\uff1a\u53d1\u9001HTTP\u8bf7\u6c42\u3001\u89e3\u6790 [&hellip;]","protected":false},"author":3,"featured_media":1068896,"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\/1068889"}],"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=1068889"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1068889\/revisions"}],"predecessor-version":[{"id":1068899,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1068889\/revisions\/1068899"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1068896"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1068889"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1068889"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1068889"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}