{"id":914,"date":"2025-01-12T10:10:59","date_gmt":"2025-01-12T02:10:59","guid":{"rendered":"https:\/\/www.laixuexila.com\/?p=914"},"modified":"2025-01-12T10:10:59","modified_gmt":"2025-01-12T02:10:59","slug":"python%e5%a6%82%e4%bd%95%e8%87%aa%e5%8a%a8%e5%8c%96%e7%88%ac%e8%99%ab%ef%bc%9a%e4%bb%8e%e9%9b%b6%e5%bc%80%e5%a7%8b%e7%9a%84%e7%88%ac%e8%99%ab%e6%95%99%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/www.laixuexila.com\/index.php\/2025\/01\/12\/python%e5%a6%82%e4%bd%95%e8%87%aa%e5%8a%a8%e5%8c%96%e7%88%ac%e8%99%ab%ef%bc%9a%e4%bb%8e%e9%9b%b6%e5%bc%80%e5%a7%8b%e7%9a%84%e7%88%ac%e8%99%ab%e6%95%99%e7%a8%8b\/","title":{"rendered":"Python\u5982\u4f55\u81ea\u52a8\u5316\u722c\u866b\uff1a\u4ece\u96f6\u5f00\u59cb\u7684\u722c\u866b\u6559\u7a0b"},"content":{"rendered":"\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>\u81ea\u52a8\u5316\u722c\u866b\uff08Web Scraping\uff09\u662f\u6307\u4f7f\u7528\u7a0b\u5e8f\u81ea\u52a8\u4ece\u7f51\u9875\u4e0a\u63d0\u53d6\u6570\u636e\uff0c\u5e7f\u6cdb\u5e94\u7528\u4e8e\u6570\u636e\u6536\u96c6\u3001\u5206\u6790\u548c\u4fe1\u606f\u63d0\u53d6\u7b49\u9886\u57df\u3002Python \u662f\u6700\u5e38\u7528\u4e8e\u7f16\u5199\u722c\u866b\u7684\u7f16\u7a0b\u8bed\u8a00\uff0c\u56e0\u5176\u8bed\u6cd5\u7b80\u6d01\u4e14\u6709\u4e30\u5bcc\u7684\u5e93\u652f\u6301\uff0c\u5c24\u5176\u9002\u7528\u4e8e\u5feb\u901f\u5f00\u53d1\u548c\u6784\u5efa\u722c\u866b\u3002<\/p>\n<\/blockquote>\n\n\n\n<p>\u672c\u6559\u7a0b\u5c06\u5e26\u4f60\u4ece\u96f6\u5f00\u59cb\uff0c\u5b66\u4e60\u5982\u4f55\u7528 Python \u7f16\u5199\u7b80\u5355\u7684\u722c\u866b\uff0c\u5e76\u4f7f\u7528\u4e00\u4e9b\u5e38\u89c1\u7684\u5e93\u548c\u5de5\u5177\u8fdb\u884c\u6570\u636e\u6293\u53d6\u3001\u5904\u7406\u548c\u4fdd\u5b58\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u4e00\u3001\u722c\u866b\u7684\u57fa\u672c\u6982\u5ff5<\/h3>\n\n\n\n<p>\u722c\u866b\u901a\u8fc7\u5411\u76ee\u6807\u7f51\u7ad9\u53d1\u9001\u8bf7\u6c42\uff0c\u83b7\u53d6\u9875\u9762\u7684 HTML \u5185\u5bb9\uff0c\u518d\u901a\u8fc7\u89e3\u6790 HTML \u63d0\u53d6\u6211\u4eec\u9700\u8981\u7684\u6570\u636e\u3002\u722c\u866b\u7684\u57fa\u672c\u6d41\u7a0b\u5982\u4e0b\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u53d1\u9001\u8bf7\u6c42<\/strong>\uff1a\u5411\u76ee\u6807\u7f51\u7ad9\u53d1\u9001 HTTP \u8bf7\u6c42\uff08\u5982 GET \u8bf7\u6c42\uff09\u3002<\/li>\n\n\n\n<li><strong>\u83b7\u53d6\u54cd\u5e94<\/strong>\uff1a\u83b7\u53d6\u7f51\u7ad9\u8fd4\u56de\u7684 HTML \u9875\u9762\u5185\u5bb9\u3002<\/li>\n\n\n\n<li><strong>\u89e3\u6790\u6570\u636e<\/strong>\uff1a\u901a\u8fc7\u89e3\u6790 HTML \u9875\u9762\u63d0\u53d6\u9700\u8981\u7684\u6570\u636e\u3002<\/li>\n\n\n\n<li><strong>\u5b58\u50a8\u6570\u636e<\/strong>\uff1a\u5c06\u722c\u53d6\u7684\u6570\u636e\u4fdd\u5b58\u5230\u672c\u5730\u6587\u4ef6\u3001\u6570\u636e\u5e93\u7b49\u3002<\/li>\n\n\n\n<li><strong>\u81ea\u52a8\u5316\u64cd\u4f5c<\/strong>\uff1a\u5728\u76ee\u6807\u7f51\u7ad9\u4e0a\u8fdb\u884c\u6279\u91cf\u722c\u53d6\uff0c\u53ef\u80fd\u6d89\u53ca\u5206\u9875\u3001\u8868\u5355\u63d0\u4ea4\u7b49\u64cd\u4f5c\u3002<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">\u4e8c\u3001Python\u722c\u866b\u6240\u9700\u7684\u5de5\u5177<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">1. <strong>requests<\/strong>\uff1a\u53d1\u9001 HTTP \u8bf7\u6c42<\/h4>\n\n\n\n<p><code>requests<\/code> \u662f Python \u4e2d\u6700\u5e38\u7528\u7684\u5e93\u4e4b\u4e00\uff0c\u7b80\u5316\u4e86\u53d1\u9001 HTTP \u8bf7\u6c42\u548c\u5904\u7406\u54cd\u5e94\u7684\u8fc7\u7a0b\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install requests<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">2. <strong>BeautifulSoup<\/strong>\uff1a\u89e3\u6790 HTML \u9875\u9762<\/h4>\n\n\n\n<p><code>BeautifulSoup<\/code> \u662f\u4e00\u4e2a Python \u5e93\uff0c\u7528\u4e8e\u89e3\u6790 HTML \u548c XML \u6587\u4ef6\uff0c\u652f\u6301\u4ece\u7f51\u9875\u4e2d\u63d0\u53d6\u6570\u636e\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install beautifulsoup4<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">3. <strong>lxml<\/strong>\uff08\u53ef\u9009\uff09\uff1a\u63d0\u9ad8\u89e3\u6790\u901f\u5ea6<\/h4>\n\n\n\n<p><code>lxml<\/code> \u662f\u4e00\u4e2a\u529f\u80fd\u5f3a\u5927\u7684 XML \u548c HTML \u89e3\u6790\u5e93\uff0c\u6bd4 <code>BeautifulSoup<\/code> \u66f4\u5feb\u3002\u5b83\u662f\u53ef\u9009\u7684\uff0c\u4f46\u5728\u5904\u7406\u5927\u578b\u9875\u9762\u65f6\u975e\u5e38\u6709\u7528\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install lxml<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">4. <strong>pandas<\/strong>\uff08\u53ef\u9009\uff09\uff1a\u5b58\u50a8\u548c\u5904\u7406\u6570\u636e<\/h4>\n\n\n\n<p><code>pandas<\/code> \u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u6570\u636e\u5904\u7406\u5e93\uff0c\u9002\u7528\u4e8e\u5c06\u6293\u53d6\u7684\u6570\u636e\u8f6c\u6362\u6210 DataFrame \u683c\u5f0f\uff0c\u8fdb\u884c\u8fdb\u4e00\u6b65\u5904\u7406\u6216\u4fdd\u5b58\u4e3a CSV \u6587\u4ef6\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install pandas<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u4e09\u3001\u7f16\u5199\u7b2c\u4e00\u4e2a\u722c\u866b<\/h3>\n\n\n\n<p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u901a\u8fc7\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\u5c55\u793a\u5982\u4f55\u4f7f\u7528 Python \u7f16\u5199\u4e00\u4e2a\u57fa\u672c\u7684\u722c\u866b\uff0c\u6293\u53d6\u67d0\u4e2a\u7f51\u9875\u7684\u6570\u636e\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">1. <strong>\u53d1\u9001\u8bf7\u6c42\u5e76\u83b7\u53d6\u9875\u9762\u5185\u5bb9<\/strong><\/h4>\n\n\n\n<p>\u6211\u4eec\u9996\u5148\u7528 <code>requests<\/code> \u5e93\u53d1\u9001 HTTP \u8bf7\u6c42\uff0c\u83b7\u53d6\u76ee\u6807\u7f51\u9875\u7684 HTML \u5185\u5bb9\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import requests\n\n# \u76ee\u6807\u7f51\u9875 URL\nurl = 'https:\/\/example.com'\n\n# \u53d1\u9001 GET \u8bf7\u6c42\nresponse = requests.get(url)\n\n# \u68c0\u67e5\u54cd\u5e94\u72b6\u6001\u7801\u662f\u5426\u4e3a 200\uff08\u6210\u529f\uff09\nif response.status_code == 200:\n    print(response.text)  # \u6253\u5370\u7f51\u9875\u7684 HTML \u5185\u5bb9\nelse:\n    print('Failed to retrieve the page')<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">2. <strong>\u4f7f\u7528 BeautifulSoup \u89e3\u6790 HTML<\/strong><\/h4>\n\n\n\n<p>\u83b7\u53d6\u9875\u9762\u5185\u5bb9\u540e\uff0c\u4f7f\u7528 <code>BeautifulSoup<\/code> \u89e3\u6790\u7f51\u9875\u7684 HTML \u4ee3\u7801\uff0c\u63d0\u53d6\u51fa\u6211\u4eec\u9700\u8981\u7684\u6570\u636e\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from bs4 import BeautifulSoup\n\n# \u4f7f\u7528 BeautifulSoup \u89e3\u6790\u7f51\u9875\nsoup = BeautifulSoup(response.text, 'html.parser')\n\n# \u67e5\u627e\u6240\u6709\u7684 &lt;a&gt; \u6807\u7b7e\nlinks = soup.find_all('a')\n\n# \u6253\u5370\u6240\u6709\u7684\u94fe\u63a5\nfor link in links:\n    print(link.get('href'))<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">3. <strong>\u63d0\u53d6\u7279\u5b9a\u6570\u636e<\/strong><\/h4>\n\n\n\n<p>\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7 <code>find()<\/code> \u6216 <code>find_all()<\/code> \u65b9\u6cd5\uff0c\u7ed3\u5408 CSS \u9009\u62e9\u5668\u6765\u63d0\u53d6\u9875\u9762\u4e2d\u5177\u4f53\u7684\u6570\u636e\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u63d0\u53d6\u7f51\u9875\u6807\u9898\u7684\u4f8b\u5b50\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \u63d0\u53d6\u7f51\u9875\u6807\u9898\ntitle = soup.title.string\nprint(f'Page Title: {title}')<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">4. <strong>\u4fdd\u5b58\u6570\u636e<\/strong><\/h4>\n\n\n\n<p>\u6293\u53d6\u5230\u7684\u6570\u636e\u53ef\u4ee5\u4fdd\u5b58\u5230\u672c\u5730\u6587\u4ef6\uff0cCSV \u6587\u4ef6\u3001JSON \u6587\u4ef6\u6216\u6570\u636e\u5e93\u4e2d\u3002\u4ee5\u4e0b\u662f\u5c06\u6570\u636e\u4fdd\u5b58\u5230 CSV \u6587\u4ef6\u7684\u793a\u4f8b\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import csv\n\n# \u5047\u8bbe\u6211\u4eec\u8981\u4fdd\u5b58\u722c\u53d6\u7684\u6240\u6709\u94fe\u63a5\nlinks = &#91;link.get('href') for link in soup.find_all('a')]\n\n# \u4fdd\u5b58\u6570\u636e\u5230 CSV \u6587\u4ef6\nwith open('links.csv', mode='w', newline='') as file:\n    writer = csv.writer(file)\n    writer.writerow(&#91;'Link'])  # \u5199\u5165\u8868\u5934\n    for link in links:\n        writer.writerow(&#91;link])<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u56db\u3001\u5904\u7406\u590d\u6742\u7684\u7f51\u9875<\/h3>\n\n\n\n<p>\u6709\u4e9b\u7f51\u9875\u53ef\u80fd\u6bd4\u8f83\u590d\u6742\uff0c\u5305\u542b\u4e86\u52a8\u6001\u5185\u5bb9\uff08\u5982 JavaScript \u6e32\u67d3\u7684\u6570\u636e\uff09\uff0c\u8fd9\u65f6\u5019\u6211\u4eec\u9700\u8981\u4e00\u4e9b\u66f4\u9ad8\u7ea7\u7684\u6280\u672f\u6765\u5904\u7406\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">1. <strong>\u6a21\u62df\u6d4f\u89c8\u5668\u884c\u4e3a\uff1aSelenium<\/strong><\/h4>\n\n\n\n<p>\u5bf9\u4e8e\u52a8\u6001\u7f51\u9875\uff0c\u53ef\u4ee5\u4f7f\u7528 <code>Selenium<\/code> \u6a21\u62df\u6d4f\u89c8\u5668\u884c\u4e3a\uff0c\u52a0\u8f7d JavaScript \u6e32\u67d3\u7684\u5185\u5bb9\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install selenium<\/code><\/pre>\n\n\n\n<p>\u7136\u540e\uff0c\u4f7f\u7528\u6d4f\u89c8\u5668\u9a71\u52a8\uff08\u5982 ChromeDriver\uff09\u6765\u542f\u52a8\u6d4f\u89c8\u5668\u5e76\u722c\u53d6\u7f51\u9875\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from selenium import webdriver\n\n# \u542f\u52a8\u6d4f\u89c8\u5668\ndriver = webdriver.Chrome()\n\n# \u8bbf\u95ee\u76ee\u6807\u9875\u9762\ndriver.get('https:\/\/example.com')\n\n# \u7b49\u5f85\u9875\u9762\u52a0\u8f7d\u5b8c\u6210\ndriver.implicitly_wait(10)\n\n# \u83b7\u53d6\u9875\u9762\u6e90\u4ee3\u7801\nhtml = driver.page_source\n\n# \u4f7f\u7528 BeautifulSoup \u89e3\u6790\nsoup = BeautifulSoup(html, 'html.parser')\n\n# \u63d0\u53d6\u9875\u9762\u4e2d\u7684\u6570\u636e\nprint(soup.title.string)\n\n# \u5173\u95ed\u6d4f\u89c8\u5668\ndriver.quit()<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">2. <strong>\u5904\u7406\u5206\u9875<\/strong><\/h4>\n\n\n\n<p>\u5f88\u591a\u7f51\u7ad9\u7684\u6570\u636e\u662f\u5206\u9875\u5c55\u793a\u7684\uff0c\u722c\u866b\u9700\u8981\u5904\u7406\u5206\u9875\u5e76\u81ea\u52a8\u6293\u53d6\u591a\u4e2a\u9875\u9762\u7684\u6570\u636e\u3002\u5047\u8bbe\u6211\u4eec\u9700\u8981\u6293\u53d6\u67d0\u4e2a\u7f51\u7ad9\u7684\u6240\u6709\u6587\u7ae0\u5217\u8868\uff0c\u53ef\u4ee5\u901a\u8fc7\u5faa\u73af\u7ffb\u9875\u6765\u5b9e\u73b0\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>base_url = 'https:\/\/example.com\/page\/'\n\nfor page_num in range(1, 6):  # \u5047\u8bbe\u6211\u4eec\u8981\u6293\u53d6\u524d5\u9875\n    url = f'{base_url}{page_num}'\n    response = requests.get(url)\n\n    if response.status_code == 200:\n        soup = BeautifulSoup(response.text, 'html.parser')\n\n        # \u63d0\u53d6\u5f53\u524d\u9875\u7684\u6587\u7ae0\u6570\u636e\n        articles = soup.find_all('article')\n        for article in articles:\n            title = article.find('h2').text\n            print(f'Article Title: {title}')<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u4e94\u3001\u9075\u5faa\u722c\u866b\u7684\u9053\u5fb7\u89c4\u8303\u548c\u6cd5\u5f8b\u89c4\u5b9a<\/h3>\n\n\n\n<p>\u722c\u866b\u662f\u4e00\u9879\u5f3a\u5927\u7684\u6280\u672f\uff0c\u4f46\u5728\u4f7f\u7528\u65f6\u9700\u8981\u9075\u5faa\u7f51\u7ad9\u7684 <code>robots.txt<\/code> \u6587\u4ef6\u3001\u9075\u5b88\u6cd5\u5f8b\u6cd5\u89c4\uff0c\u907f\u514d\u5bf9\u7f51\u7ad9\u9020\u6210\u8fc7\u591a\u8d1f\u8f7d\u3002<code>robots.txt<\/code> \u6587\u4ef6\u89c4\u5b9a\u4e86\u54ea\u4e9b\u90e8\u5206\u53ef\u4ee5\u88ab\u722c\u53d6\uff0c\u54ea\u4e9b\u4e0d\u80fd\u88ab\u722c\u53d6\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">1. <strong>\u9075\u5b88 <code>robots.txt<\/code><\/strong><\/h4>\n\n\n\n<p><code>robots.txt<\/code> \u6587\u4ef6\u901a\u5e38\u4f4d\u4e8e\u7f51\u7ad9\u7684\u6839\u76ee\u5f55\uff0c\u91cc\u9762\u5305\u542b\u4e86\u722c\u866b\u53ef\u4ee5\u6293\u53d6\u7684\u89c4\u5219\u3002\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7 <code>requests<\/code> \u8bf7\u6c42\u8be5\u6587\u4ef6\uff0c\u68c0\u67e5\u7f51\u7ad9\u7684\u722c\u866b\u89c4\u5219\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>robots_url = 'https:\/\/example.com\/robots.txt'\nresponse = requests.get(robots_url)\n\nif response.status_code == 200:\n    print(response.text)  # \u6253\u5370 robots.txt \u7684\u5185\u5bb9<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">2. <strong>\u722c\u53d6\u9891\u7387\u63a7\u5236<\/strong><\/h4>\n\n\n\n<p>\u722c\u866b\u6293\u53d6\u6570\u636e\u65f6\uff0c\u5e94\u8be5\u63a7\u5236\u8bf7\u6c42\u7684\u9891\u7387\uff0c\u907f\u514d\u9891\u7e41\u8bf7\u6c42\u5bfc\u81f4\u7f51\u7ad9\u670d\u52a1\u5668\u8fc7\u8f7d\u3002\u53ef\u4ee5\u4f7f\u7528 <code>time.sleep()<\/code> \u6765\u63a7\u5236\u8bf7\u6c42\u95f4\u7684\u95f4\u9694\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import time\n\n# \u6bcf\u6b21\u8bf7\u6c42\u95f4\u9694 1 \u79d2\ntime.sleep(1)<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">3. <strong>IP \u9650\u5236\u4e0e\u4ee3\u7406\u4f7f\u7528<\/strong><\/h4>\n\n\n\n<p>\u6709\u4e9b\u7f51\u7ad9\u5bf9 IP \u5730\u5740\u505a\u4e86\u9650\u5236\uff0c\u9632\u6b62\u9891\u7e41\u8bf7\u6c42\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u4ee3\u7406\u670d\u52a1\u5668\u6765\u7ed5\u8fc7\u8fd9\u4e2a\u9650\u5236\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>proxies = {\n    'http': 'http:\/\/your_proxy',\n    'https': 'https:\/\/your_proxy'\n}\n\nresponse = requests.get('https:\/\/example.com', proxies=proxies)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u516d\u3001\u603b\u7ed3<\/h3>\n\n\n\n<p>\u901a\u8fc7\u672c\u6559\u7a0b\uff0c\u4f60\u5df2\u7ecf\u5b66\u4e60\u4e86\u5982\u4f55\u7528 Python \u7f16\u5199\u722c\u866b\u6765\u6293\u53d6\u9759\u6001\u7f51\u9875\u548c\u5904\u7406\u5206\u9875\u3001\u52a8\u6001\u5185\u5bb9\u7b49\u5e38\u89c1\u95ee\u9898\u3002\u4ee5\u4e0b\u662f\u672c\u6559\u7a0b\u7684\u51e0\u4e2a\u8981\u70b9\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u53d1\u9001\u8bf7\u6c42\u5e76\u83b7\u53d6\u54cd\u5e94<\/strong>\uff1a\u4f7f\u7528 <code>requests<\/code> \u5e93\u53d1\u9001 HTTP \u8bf7\u6c42\u3002<\/li>\n\n\n\n<li><strong>\u89e3\u6790 HTML \u5185\u5bb9<\/strong>\uff1a\u4f7f\u7528 <code>BeautifulSoup<\/code> \u89e3\u6790\u7f51\u9875\u5185\u5bb9\u5e76\u63d0\u53d6\u6570\u636e\u3002<\/li>\n\n\n\n<li><strong>\u5b58\u50a8\u6570\u636e<\/strong>\uff1a\u5c06\u6570\u636e\u4fdd\u5b58\u5230\u672c\u5730\u6587\u4ef6\u4e2d\uff08\u5982 CSV \u6216 JSON \u683c\u5f0f\uff09\u3002<\/li>\n\n\n\n<li><strong>\u5904\u7406\u52a8\u6001\u7f51\u9875<\/strong>\uff1a\u4f7f\u7528 <code>Selenium<\/code> \u6a21\u62df\u6d4f\u89c8\u5668\u884c\u4e3a\u5904\u7406\u52a8\u6001\u5185\u5bb9\u3002<\/li>\n\n\n\n<li><strong>\u9075\u5faa\u9053\u5fb7\u89c4\u8303<\/strong>\uff1a\u9075\u5b88\u7f51\u7ad9\u7684 <code>robots.txt<\/code> \u6587\u4ef6\u89c4\u5219\uff0c\u5e76\u5408\u7406\u63a7\u5236\u722c\u866b\u6293\u53d6\u9891\u7387\u3002<\/li>\n<\/ol>\n\n\n\n<p>\u722c\u866b\u662f\u4e00\u9879\u975e\u5e38\u5b9e\u7528\u7684\u6280\u672f\uff0c\u4f46\u5728\u4f7f\u7528\u65f6\u9700\u8981\u8c28\u614e\uff0c\u786e\u4fdd\u4e0d\u4f1a\u5bf9\u76ee\u6807\u7f51\u7ad9\u9020\u6210\u8fc7\u5ea6\u8d1f\u62c5\u3002\u5e0c\u671b\u4f60\u80fd\u591f\u8fd0\u7528\u8fd9\u4e9b\u6280\u5de7\uff0c\u6293\u53d6\u4f60\u9700\u8981\u7684\u6570\u636e\u5e76\u5e94\u7528\u5230\u5b9e\u9645\u9879\u76ee\u4e2d\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u81ea\u52a8\u5316\u722c\u866b\uff08Web Scraping\uff09\u662f\u6307\u4f7f\u7528\u7a0b\u5e8f\u81ea\u52a8\u4ece\u7f51\u9875\u4e0a\u63d0\u53d6\u6570\u636e\uff0c\u5e7f\u6cdb\u5e94\u7528\u4e8e\u6570\u636e\u6536\u96c6\u3001\u5206\u6790\u548c\u4fe1\u606f\u63d0\u53d6\u7b49\u9886 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-914","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts\/914","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/comments?post=914"}],"version-history":[{"count":1,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts\/914\/revisions"}],"predecessor-version":[{"id":915,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts\/914\/revisions\/915"}],"wp:attachment":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/media?parent=914"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/categories?post=914"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/tags?post=914"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}