{"id":1043239,"date":"2024-12-31T13:04:22","date_gmt":"2024-12-31T05:04:22","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1043239.html"},"modified":"2024-12-31T13:04:24","modified_gmt":"2024-12-31T05:04:24","slug":"%e5%a6%82%e4%bd%95%e7%94%a8python%e4%bb%8e%e7%bd%91%e7%ab%99%e6%8f%90%e5%8f%96%e4%bf%a1%e6%81%af","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1043239.html","title":{"rendered":"\u5982\u4f55\u7528python\u4ece\u7f51\u7ad9\u63d0\u53d6\u4fe1\u606f"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2024\/12\/b25354c2-fbc7-403c-9578-10b950540e48.webp?x-oss-process=image\/auto-orient,1\/format,webp\" alt=\"\u5982\u4f55\u7528python\u4ece\u7f51\u7ad9\u63d0\u53d6\u4fe1\u606f\" \/><\/p>\n<p><p> <strong>\u4f7f\u7528Python\u4ece\u7f51\u7ad9\u63d0\u53d6\u4fe1\u606f\u7684\u4e3b\u8981\u65b9\u6cd5\u5305\u62ec\uff1a\u4f7f\u7528requests\u5e93\u53d1\u9001HTTP\u8bf7\u6c42\u3001\u4f7f\u7528BeautifulSoup\u5e93\u89e3\u6790HTML\u3001\u4f7f\u7528Selenium\u5e93\u8fdb\u884c\u52a8\u6001\u5185\u5bb9\u6293\u53d6\u3001\u4e86\u89e3\u5e76\u9075\u5b88\u7f51\u7ad9\u7684robots.txt\u6587\u4ef6\u3002<\/strong>  <\/p>\n<\/p>\n<p><p>\u4f7f\u7528requests\u5e93\u53d1\u9001HTTP\u8bf7\u6c42\u662f\u6700\u57fa\u672c\u7684\u7f51\u9875\u6293\u53d6\u65b9\u6cd5\u4e4b\u4e00\u3002requests\u5e93\u662fPython\u4e2d\u6700\u6d41\u884c\u7684HTTP\u5e93\u4e4b\u4e00\uff0c\u80fd\u591f\u65b9\u4fbf\u5730\u53d1\u9001HTTP\u8bf7\u6c42\u5e76\u83b7\u53d6\u54cd\u5e94\u3002\u4f7f\u7528requests\u5e93\u53ef\u4ee5\u8f7b\u677e\u83b7\u53d6\u7f51\u9875\u7684HTML\u5185\u5bb9\uff0c\u4e3a\u540e\u7eed\u7684\u89e3\u6790\u63d0\u4f9b\u57fa\u7840\u3002  <\/p>\n<\/p>\n<p><h2>\u4e00\u3001\u4f7f\u7528requests\u5e93\u53d1\u9001HTTP\u8bf7\u6c42<\/h2>\n<\/p>\n<p><p>requests\u5e93\u662f\u4e00\u4e2a\u529f\u80fd\u5f3a\u5927\u4e14\u6613\u4e8e\u4f7f\u7528\u7684HTTP\u5e93\u3002\u901a\u8fc7\u5b83\uff0c\u6211\u4eec\u53ef\u4ee5\u53d1\u9001\u5404\u79cdHTTP\u8bf7\u6c42\uff0c\u5e76\u5904\u7406\u54cd\u5e94\u6570\u636e\u3002\u4ee5\u4e0b\u662f\u4f7f\u7528requests\u5e93\u53d1\u9001HTTP\u8bf7\u6c42\u7684\u57fa\u672c\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p>\u5b89\u88c5requests\u5e93<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install requests<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p>\u53d1\u9001HTTP\u8bf7\u6c42\u5e76\u83b7\u53d6\u54cd\u5e94<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import requests<\/p>\n<p>url = &#39;https:\/\/example.com&#39;<\/p>\n<p>response = requests.get(url)<\/p>\n<p>if response.status_code == 200:<\/p>\n<p>    html_content = response.text<\/p>\n<p>    print(html_content)<\/p>\n<p>else:<\/p>\n<p>    print(f&quot;F<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>led to retrieve the webpage. Status code: {response.status_code}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u9996\u5148\u5bfc\u5165requests\u5e93\uff0c\u7136\u540e\u5b9a\u4e49\u76ee\u6807URL\u5e76\u53d1\u9001GET\u8bf7\u6c42\u3002\u5982\u679c\u8bf7\u6c42\u6210\u529f\uff0c\u6211\u4eec\u5c06HTML\u5185\u5bb9\u5b58\u50a8\u5728<code>html_content<\/code>\u53d8\u91cf\u4e2d\uff0c\u5e76\u8f93\u51fa\u8be5\u5185\u5bb9\u3002<\/p>\n<\/p>\n<p><h2>\u4e8c\u3001\u4f7f\u7528BeautifulSoup\u5e93\u89e3\u6790HTML<\/h2>\n<\/p>\n<p><p>BeautifulSoup\u662f\u4e00\u4e2a\u7528\u4e8e\u89e3\u6790HTML\u548cXML\u7684Python\u5e93\u3002\u5b83\u53ef\u4ee5\u4ece\u7f51\u9875\u4e2d\u63d0\u53d6\u6570\u636e\uff0c\u5e76\u5c06\u5176\u8f6c\u6362\u4e3a\u7ed3\u6784\u5316\u7684\u683c\u5f0f\u3002\u4ee5\u4e0b\u662f\u4f7f\u7528BeautifulSoup\u5e93\u89e3\u6790HTML\u7684\u57fa\u672c\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p>\u5b89\u88c5BeautifulSoup\u5e93<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install beautifulsoup4<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p>\u4f7f\u7528BeautifulSoup\u89e3\u6790HTML\u5e76\u63d0\u53d6\u4fe1\u606f<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from bs4 import BeautifulSoup<\/p>\n<p>soup = BeautifulSoup(html_content, &#39;html.parser&#39;)<\/p>\n<p>title = soup.title.string<\/p>\n<p>print(f&quot;Title of the webpage: {title}&quot;)<\/p>\n<h2><strong>\u63d0\u53d6\u6240\u6709\u7684\u94fe\u63a5<\/strong><\/h2>\n<p>links = soup.find_all(&#39;a&#39;)<\/p>\n<p>for link in links:<\/p>\n<p>    print(link.get(&#39;href&#39;))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u9996\u5148\u5bfc\u5165BeautifulSoup\u5e93\uff0c\u5e76\u5c06HTML\u5185\u5bb9\u4f20\u9012\u7ed9BeautifulSoup\u5bf9\u8c61\u8fdb\u884c\u89e3\u6790\u3002\u7136\u540e\uff0c\u6211\u4eec\u63d0\u53d6\u7f51\u9875\u7684\u6807\u9898\uff0c\u5e76\u8f93\u51fa\u6240\u6709\u7684\u94fe\u63a5\u3002<\/p>\n<\/p>\n<p><h2>\u4e09\u3001\u4f7f\u7528Selenium\u5e93\u8fdb\u884c\u52a8\u6001\u5185\u5bb9\u6293\u53d6<\/h2>\n<\/p>\n<p><p>\u6709\u4e9b\u7f51\u7ad9\u4f7f\u7528JavaScript\u52a8\u6001\u52a0\u8f7d\u5185\u5bb9\uff0c\u8fd9\u4f7f\u5f97requests\u548cBeautifulSoup\u65e0\u6cd5\u76f4\u63a5\u83b7\u53d6\u6240\u9700\u7684\u6570\u636e\u3002\u6b64\u65f6\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528Selenium\u5e93\u8fdb\u884c\u52a8\u6001\u5185\u5bb9\u6293\u53d6\u3002Selenium\u662f\u4e00\u4e2a\u7528\u4e8e\u81ea\u52a8\u5316Web\u6d4f\u89c8\u5668\u64cd\u4f5c\u7684\u5e93\uff0c\u53ef\u4ee5\u6a21\u62df\u7528\u6237\u884c\u4e3a\uff0c\u5e76\u83b7\u53d6\u52a8\u6001\u52a0\u8f7d\u7684\u5185\u5bb9\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p>\u5b89\u88c5Selenium\u5e93\u548cWebDriver<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install selenium<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p>\u4e0b\u8f7d\u9002\u7528\u4e8e\u6240\u7528\u6d4f\u89c8\u5668\u7684WebDriver\uff08\u5982ChromeDriver\u3001GeckoDriver\u7b49\uff09\uff0c\u5e76\u5c06\u5176\u8def\u5f84\u6dfb\u52a0\u5230\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\u4e2d\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p>\u4f7f\u7528Selenium\u83b7\u53d6\u52a8\u6001\u5185\u5bb9<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from selenium import webdriver<\/p>\n<p>from selenium.webdriver.common.by import By<\/p>\n<p>from selenium.webdriver.common.keys import Keys<\/p>\n<p>driver = webdriver.Chrome()  # \u6216\u8005\u4f7f\u7528webdriver.Firefox()<\/p>\n<p>driver.get(&#39;https:\/\/example.com&#39;)<\/p>\n<h2><strong>\u7b49\u5f85\u9875\u9762\u52a0\u8f7d\u5b8c\u6210\uff0c\u5e76\u83b7\u53d6\u6240\u9700\u7684\u52a8\u6001\u5185\u5bb9<\/strong><\/h2>\n<p>title = driver.title<\/p>\n<p>print(f&quot;Title of the webpage: {title}&quot;)<\/p>\n<h2><strong>\u63d0\u53d6\u6240\u6709\u7684\u94fe\u63a5<\/strong><\/h2>\n<p>links = driver.find_elements(By.TAG_NAME, &#39;a&#39;)<\/p>\n<p>for link in links:<\/p>\n<p>    print(link.get_attribute(&#39;href&#39;))<\/p>\n<p>driver.quit()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528Selenium\u5e93\u542f\u52a8Chrome\u6d4f\u89c8\u5668\uff0c\u5e76\u8bbf\u95ee\u76ee\u6807URL\u3002\u7136\u540e\uff0c\u6211\u4eec\u7b49\u5f85\u9875\u9762\u52a0\u8f7d\u5b8c\u6210\uff0c\u5e76\u83b7\u53d6\u7f51\u9875\u7684\u6807\u9898\u548c\u6240\u6709\u7684\u94fe\u63a5\u3002\u6700\u540e\uff0c\u5173\u95ed\u6d4f\u89c8\u5668\u3002<\/p>\n<\/p>\n<p><h2>\u56db\u3001\u4e86\u89e3\u5e76\u9075\u5b88\u7f51\u7ad9\u7684robots.txt\u6587\u4ef6<\/h2>\n<\/p>\n<p><p>\u5728\u8fdb\u884c\u7f51\u9875\u6293\u53d6\u65f6\uff0c\u6211\u4eec\u9700\u8981\u9075\u5b88\u7f51\u7ad9\u7684robots.txt\u6587\u4ef6\u3002robots.txt\u6587\u4ef6\u7528\u4e8e\u6307\u5b9a\u54ea\u4e9b\u90e8\u5206\u7684\u5185\u5bb9\u5141\u8bb8\u88ab\u641c\u7d22\u5f15\u64ce\u6293\u53d6\uff0c\u54ea\u4e9b\u90e8\u5206\u4e0d\u5141\u8bb8\u3002\u901a\u8fc7\u9075\u5b88robots.txt\u6587\u4ef6\u4e2d\u7684\u89c4\u5219\uff0c\u6211\u4eec\u53ef\u4ee5\u786e\u4fdd\u81ea\u5df1\u7684\u6293\u53d6\u884c\u4e3a\u5408\u6cd5\u4e14\u5c0a\u91cd\u7f51\u7ad9\u7684\u610f\u613f\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p>\u83b7\u53d6robots.txt\u6587\u4ef6<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">robots_url = &#39;https:\/\/example.com\/robots.txt&#39;<\/p>\n<p>response = requests.get(robots_url)<\/p>\n<p>if response.status_code == 200:<\/p>\n<p>    robots_content = response.text<\/p>\n<p>    print(robots_content)<\/p>\n<p>else:<\/p>\n<p>    print(f&quot;Failed to retrieve the robots.txt file. Status code: {response.status_code}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p>\u89e3\u6790robots.txt\u6587\u4ef6<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from urllib.robotparser import RobotFileParser<\/p>\n<p>robots_parser = RobotFileParser()<\/p>\n<p>robots_parser.set_url(robots_url)<\/p>\n<p>robots_parser.read()<\/p>\n<p>user_agent = &#39;*&#39;<\/p>\n<p>target_url = &#39;https:\/\/example.com\/some-page&#39;<\/p>\n<p>if robots_parser.can_fetch(user_agent, target_url):<\/p>\n<p>    print(f&quot;Allowed to scrape {target_url}&quot;)<\/p>\n<p>else:<\/p>\n<p>    print(f&quot;Not allowed to scrape {target_url}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u9996\u5148\u83b7\u53d6\u5e76\u6253\u5370robots.txt\u6587\u4ef6\u7684\u5185\u5bb9\u3002\u7136\u540e\uff0c\u6211\u4eec\u4f7f\u7528<code>RobotFileParser<\/code>\u7c7b\u89e3\u6790robots.txt\u6587\u4ef6\uff0c\u5e76\u68c0\u67e5\u662f\u5426\u5141\u8bb8\u6293\u53d6\u76ee\u6807URL\u3002<\/p>\n<\/p>\n<p><h2>\u4e94\u3001\u5904\u7406\u7f51\u9875\u6293\u53d6\u4e2d\u7684\u5e38\u89c1\u95ee\u9898<\/h2>\n<\/p>\n<p><p>\u5728\u8fdb\u884c\u7f51\u9875\u6293\u53d6\u65f6\uff0c\u6211\u4eec\u53ef\u80fd\u4f1a\u9047\u5230\u4e00\u4e9b\u5e38\u89c1\u95ee\u9898\uff0c\u5982\u53cd\u722c\u866b\u673a\u5236\u3001IP\u5c01\u7981\u3001\u6570\u636e\u683c\u5f0f\u4e0d\u4e00\u81f4\u7b49\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e94\u5bf9\u7b56\u7565\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\u514d\u56e0\u4e3a\u9891\u7e41\u8bf7\u6c42\u800c\u5bfc\u81f4\u7684IP\u5c01\u7981\u3002<\/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;https:\/\/your_proxy_ip:port&#39;<\/p>\n<p>}<\/p>\n<p>response = requests.get(url, proxies=proxies)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6a21\u62df\u7528\u6237\u884c\u4e3a<\/strong>\uff1a\u901a\u8fc7\u8bbe\u7f6e\u8bf7\u6c42\u5934\uff08\u5982User-Agent\u3001Referer\u7b49\uff09\uff0c\u53ef\u4ee5\u6a21\u62df\u771f\u5b9e\u7528\u6237\u7684\u884c\u4e3a\uff0c\u51cf\u5c11\u88ab\u8bc6\u522b\u4e3a\u722c\u866b\u7684\u6982\u7387\u3002<\/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\/91.0.4472.124 Safari\/537.36&#39;<\/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>\u4f7f\u7528\u5ef6\u65f6\u548c\u968f\u673a\u95f4\u9694<\/strong>\uff1a\u5728\u53d1\u9001\u8bf7\u6c42\u65f6\u52a0\u5165\u5ef6\u65f6\u548c\u968f\u673a\u95f4\u9694\uff0c\u53ef\u4ee5\u51cf\u5c11\u8bf7\u6c42\u9891\u7387\uff0c\u964d\u4f4e\u88ab\u5c01\u7981\u7684\u98ce\u9669\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import time<\/p>\n<p>import random<\/p>\n<p>time.sleep(random.uniform(1, 3))<\/p>\n<p>response = requests.get(url)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5904\u7406\u6570\u636e\u683c\u5f0f\u4e0d\u4e00\u81f4<\/strong>\uff1a\u5728\u89e3\u6790\u6570\u636e\u65f6\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u6570\u636e\u683c\u5f0f\u4e0d\u4e00\u81f4\u7684\u95ee\u9898\u3002\u53ef\u4ee5\u901a\u8fc7\u6b63\u5219\u8868\u8fbe\u5f0f\u3001\u6761\u4ef6\u5224\u65ad\u7b49\u65b9\u6cd5\u8fdb\u884c\u5904\u7406\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import re<\/p>\n<p>html_content = &quot;&lt;html&gt;&lt;body&gt;&lt;p&gt;Price: $123.45&lt;\/p&gt;&lt;\/body&gt;&lt;\/html&gt;&quot;<\/p>\n<p>match = re.search(r&#39;Price: \\$([\\d\\.]+)&#39;, html_content)<\/p>\n<p>if match:<\/p>\n<p>    price = match.group(1)<\/p>\n<p>    print(f&quot;Price: {price}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><h2>\u516d\u3001\u603b\u7ed3<\/h2>\n<\/p>\n<p><p>\u901a\u8fc7\u4f7f\u7528requests\u5e93\u3001BeautifulSoup\u5e93\u548cSelenium\u5e93\uff0c\u6211\u4eec\u53ef\u4ee5\u4ece\u7f51\u7ad9\u4e2d\u63d0\u53d6\u4fe1\u606f\u3002requests\u5e93\u7528\u4e8e\u53d1\u9001HTTP\u8bf7\u6c42\u5e76\u83b7\u53d6\u7f51\u9875\u5185\u5bb9\uff0cBeautifulSoup\u5e93\u7528\u4e8e\u89e3\u6790HTML\u5e76\u63d0\u53d6\u6570\u636e\uff0c\u800cSelenium\u5e93\u5219\u7528\u4e8e\u5904\u7406\u52a8\u6001\u52a0\u8f7d\u7684\u5185\u5bb9\u3002\u5728\u8fdb\u884c\u7f51\u9875\u6293\u53d6\u65f6\uff0c\u6211\u4eec\u9700\u8981\u4e86\u89e3\u5e76\u9075\u5b88\u7f51\u7ad9\u7684robots.txt\u6587\u4ef6\uff0c\u786e\u4fdd\u6293\u53d6\u884c\u4e3a\u5408\u6cd5\u3002\u6b64\u5916\uff0c\u8fd8\u9700\u8981\u5e94\u5bf9\u7f51\u9875\u6293\u53d6\u4e2d\u7684\u5e38\u89c1\u95ee\u9898\uff0c\u5982\u53cd\u722c\u866b\u673a\u5236\u3001IP\u5c01\u7981\u7b49\u3002\u901a\u8fc7\u5408\u7406\u4f7f\u7528\u8fd9\u4e9b\u5de5\u5177\u548c\u7b56\u7565\uff0c\u6211\u4eec\u53ef\u4ee5\u9ad8\u6548\u5730\u4ece\u7f51\u7ad9\u4e2d\u63d0\u53d6\u6240\u9700\u7684\u4fe1\u606f\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\u63d0\u53d6\u7f51\u7ad9\u4fe1\u606f\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u6709\u591a\u4e2a\u5e93\u53ef\u4ee5\u7528\u6765\u63d0\u53d6\u7f51\u7ad9\u4fe1\u606f\u3002\u5e38\u7528\u7684\u5e93\u5305\u62ecBeautiful Soup\u3001Scrapy\u548cRequests\u3002Beautiful Soup\u9002\u5408\u5c0f\u89c4\u6a21\u6570\u636e\u63d0\u53d6\uff0c\u5177\u6709\u5f3a\u5927\u7684HTML\u89e3\u6790\u80fd\u529b\uff1bScrapy\u5219\u662f\u4e00\u4e2a\u529f\u80fd\u5f3a\u5927\u7684\u6846\u67b6\uff0c\u9002\u5408\u5927\u89c4\u6a21\u6293\u53d6\uff1bRequests\u5219\u7528\u4e8e\u53d1\u9001HTTP\u8bf7\u6c42\u5e76\u83b7\u53d6\u54cd\u5e94\u3002\u9009\u62e9\u5408\u9002\u7684\u5e93\u53d6\u51b3\u4e8e\u4f60\u8981\u63d0\u53d6\u7684\u6570\u636e\u91cf\u548c\u590d\u6742\u6027\u3002<\/p>\n<p><strong>\u63d0\u53d6\u7f51\u7ad9\u4fe1\u606f\u65f6\u5982\u4f55\u5904\u7406\u53cd\u722c\u866b\u673a\u5236\uff1f<\/strong><br \/>\u8bb8\u591a\u7f51\u7ad9\u4f1a\u5b9e\u65bd\u53cd\u722c\u866b\u673a\u5236\u6765\u4fdd\u62a4\u5176\u6570\u636e\uff0c\u5e38\u89c1\u7684\u63aa\u65bd\u5305\u62ecIP\u5c01\u9501\u548c\u4f7f\u7528\u9a8c\u8bc1\u7801\u3002\u4e3a\u4e86\u5e94\u5bf9\u8fd9\u4e9b\u6311\u6218\uff0c\u53ef\u4ee5\u91c7\u53d6\u4e00\u4e9b\u7b56\u7565\u3002\u4f8b\u5982\uff0c\u4f7f\u7528\u968f\u673a\u7684\u7528\u6237\u4ee3\u7406\uff08User-Agent\uff09\u6765\u6a21\u62df\u4e0d\u540c\u7684\u6d4f\u89c8\u5668\u8bbf\u95ee\uff0c\u6216\u8005\u4f7f\u7528\u4ee3\u7406IP\u6765\u5206\u6563\u8bf7\u6c42\u3002\u6b64\u5916\uff0c\u901a\u8fc7\u8bbe\u7f6e\u9002\u5f53\u7684\u8bf7\u6c42\u95f4\u9694\u6765\u964d\u4f4e\u8bbf\u95ee\u9891\u7387\uff0c\u4e5f\u6709\u52a9\u4e8e\u907f\u514d\u88ab\u7f51\u7ad9\u8bc6\u522b\u4e3a\u722c\u866b\u3002<\/p>\n<p><strong>\u63d0\u53d6\u4fe1\u606f\u540e\u5982\u4f55\u5b58\u50a8\u548c\u5904\u7406\u6570\u636e\uff1f<\/strong><br \/>\u4ece\u7f51\u7ad9\u63d0\u53d6\u7684\u4fe1\u606f\u53ef\u4ee5\u5b58\u50a8\u5728\u591a\u79cd\u683c\u5f0f\u4e2d\uff0c\u5982CSV\u3001JSON\u6216\u6570\u636e\u5e93\u3002\u5bf9\u4e8e\u5c0f\u578b\u9879\u76ee\uff0c\u53ef\u4ee5\u4f7f\u7528CSV\u6216JSON\u683c\u5f0f\u4fdd\u5b58\u6570\u636e\uff0c\u8fd9\u6837\u65b9\u4fbf\u540e\u7eed\u5206\u6790\u3002\u800c\u5bf9\u4e8e\u5927\u578b\u9879\u76ee\uff0c\u5efa\u8bae\u4f7f\u7528\u5173\u7cfb\u578b\u6570\u636e\u5e93\u5982MySQL\u6216\u975e\u5173\u7cfb\u578b\u6570\u636e\u5e93\u5982MongoDB\uff0c\u80fd\u591f\u66f4\u9ad8\u6548\u5730\u7ba1\u7406\u548c\u67e5\u8be2\u6570\u636e\u3002\u540c\u65f6\uff0c\u53ef\u4ee5\u5229\u7528Pandas\u7b49\u6570\u636e\u5206\u6790\u5e93\u5bf9\u63d0\u53d6\u7684\u6570\u636e\u8fdb\u884c\u8fdb\u4e00\u6b65\u5904\u7406\u548c\u5206\u6790\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u4f7f\u7528Python\u4ece\u7f51\u7ad9\u63d0\u53d6\u4fe1\u606f\u7684\u4e3b\u8981\u65b9\u6cd5\u5305\u62ec\uff1a\u4f7f\u7528requests\u5e93\u53d1\u9001HTTP\u8bf7\u6c42\u3001\u4f7f\u7528BeautifulS [&hellip;]","protected":false},"author":3,"featured_media":1043250,"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\/1043239"}],"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=1043239"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1043239\/revisions"}],"predecessor-version":[{"id":1043256,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1043239\/revisions\/1043256"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1043250"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1043239"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1043239"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1043239"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}