{"id":1040862,"date":"2024-12-31T12:44:28","date_gmt":"2024-12-31T04:44:28","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1040862.html"},"modified":"2024-12-31T12:44:30","modified_gmt":"2024-12-31T04:44:30","slug":"python%e5%a6%82%e4%bd%95%e5%9c%a8%e7%99%be%e5%ba%a6%e7%88%ac%e6%95%b0%e6%8d%ae","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1040862.html","title":{"rendered":"python\u5982\u4f55\u5728\u767e\u5ea6\u722c\u6570\u636e"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2024\/12\/bec397aa-0ac3-4fb3-b1f1-1ddba74cd06e.webp?x-oss-process=image\/auto-orient,1\/format,webp\" alt=\"python\u5982\u4f55\u5728\u767e\u5ea6\u722c\u6570\u636e\" \/><\/p>\n<p><p> <strong>\u5982\u4f55\u4f7f\u7528Python\u5728\u767e\u5ea6\u722c\u53d6\u6570\u636e<\/strong><\/p>\n<\/p>\n<p><p>\u8981\u4f7f\u7528Python\u5728\u767e\u5ea6\u4e0a\u722c\u53d6\u6570\u636e\uff0c\u53ef\u4ee5\u4f7f\u7528<strong>requests\u3001BeautifulSoup\u3001selenium<\/strong>\u7b49\u5de5\u5177\u6765\u53d1\u9001HTTP\u8bf7\u6c42\u3001\u89e3\u6790HTML\u9875\u9762\u3001\u6a21\u62df\u7528\u6237\u64cd\u4f5c\u7b49\u3002\u672c\u6587\u5c06\u8be6\u7ec6\u8bb2\u89e3\u5982\u4f55\u4f7f\u7528\u8fd9\u4e9b\u5de5\u5177\u6765\u722c\u53d6\u767e\u5ea6\u4e0a\u7684\u6570\u636e\u3002\u672c\u6587\u7684\u6838\u5fc3\u89c2\u70b9\u6709\uff1a\u901a\u8fc7\u53d1\u9001HTTP\u8bf7\u6c42\u83b7\u53d6\u7f51\u9875\u5185\u5bb9\u3001\u4f7f\u7528BeautifulSoup\u89e3\u6790HTML\u3001\u5229\u7528Selenium\u6a21\u62df\u7528\u6237\u64cd\u4f5c\u3001\u9075\u5faa\u53cd\u722c\u866b\u7b56\u7565\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u5c55\u5f00\u5176\u4e2d\u7684<strong>\u901a\u8fc7\u53d1\u9001HTTP\u8bf7\u6c42\u83b7\u53d6\u7f51\u9875\u5185\u5bb9<\/strong>\u7684\u8bb2\u89e3\u3002<\/p>\n<\/p>\n<p><p>\u901a\u8fc7\u53d1\u9001HTTP\u8bf7\u6c42\u83b7\u53d6\u7f51\u9875\u5185\u5bb9\u662f\u722c\u53d6\u6570\u636e\u7684\u7b2c\u4e00\u6b65\u3002Python\u7684requests\u5e93\u662f\u4e00\u4e2a\u975e\u5e38\u6d41\u884c\u7684HTTP\u5e93\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u53d1\u9001GET\u3001POST\u8bf7\u6c42\u5e76\u83b7\u53d6\u54cd\u5e94\u3002\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u5b89\u88c5requests\u5e93\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">pip install requests<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528requests\u5e93\u53d1\u9001GET\u8bf7\u6c42\u83b7\u53d6\u767e\u5ea6\u641c\u7d22\u7ed3\u679c\u9875\u9762\u7684HTML\u5185\u5bb9\u3002\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import requests<\/p>\n<p>url = &#39;https:\/\/www.b<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>du.com\/s?wd=python&#39;<\/p>\n<p>response = requests.get(url)<\/p>\n<p>if response.status_code == 200:<\/p>\n<p>    print(response.text)<\/p>\n<p>else:<\/p>\n<p>    print(&#39;Failed to retrieve the page&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e2a\u793a\u4f8b\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u901a\u8fc7GET\u8bf7\u6c42\u83b7\u53d6\u767e\u5ea6\u641c\u7d22\u5173\u952e\u8bcd\u201cpython\u201d\u7684\u7ed3\u679c\u9875\u9762\uff0c\u5e76\u6253\u5370\u51fa\u9875\u9762\u7684HTML\u5185\u5bb9\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528BeautifulSoup\u89e3\u6790HTML\u9875\u9762\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u901a\u8fc7\u53d1\u9001HTTP\u8bf7\u6c42\u83b7\u53d6\u7f51\u9875\u5185\u5bb9<\/h3>\n<\/p>\n<p><p>\u53d1\u9001HTTP\u8bf7\u6c42\u662f\u722c\u53d6\u7f51\u9875\u5185\u5bb9\u7684\u7b2c\u4e00\u6b65\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528Python\u7684requests\u5e93\u6765\u53d1\u9001GET\u8bf7\u6c42\uff0c\u4ece\u800c\u83b7\u53d6\u7f51\u9875\u7684HTML\u5185\u5bb9\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>url = &#39;https:\/\/www.baidu.com\/s?wd=python&#39;<\/p>\n<p>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>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(&#39;Failed to retrieve the page&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u6dfb\u52a0\u4e86\u4e00\u4e2a<code>headers<\/code>\u53c2\u6570\uff0c\u5176\u4e2d\u5305\u542b\u4e86User-Agent\uff0c\u6a21\u62df\u4e00\u4e2a\u6d4f\u89c8\u5668\u8bf7\u6c42\uff0c\u907f\u514d\u88ab\u670d\u52a1\u5668\u8bc6\u522b\u4e3a\u722c\u866b\u3002\u8fd9\u6bb5\u4ee3\u7801\u5c06\u83b7\u53d6\u767e\u5ea6\u641c\u7d22\u201cpython\u201d\u5173\u952e\u8bcd\u7684\u7ed3\u679c\u9875\u9762\uff0c\u5e76\u5c06HTML\u5185\u5bb9\u5b58\u50a8\u5728<code>html_content<\/code>\u53d8\u91cf\u4e2d\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u4f7f\u7528BeautifulSoup\u89e3\u6790HTML<\/h3>\n<\/p>\n<p><p>\u83b7\u53d6HTML\u5185\u5bb9\u540e\uff0c\u6211\u4eec\u9700\u8981\u89e3\u6790\u8fd9\u4e9b\u5185\u5bb9\u4ee5\u63d0\u53d6\u6709\u7528\u7684\u4fe1\u606f\u3002BeautifulSoup\u662f\u4e00\u4e2a\u975e\u5e38\u6d41\u884c\u7684HTML\u89e3\u6790\u5e93\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u89e3\u6790\u548c\u63d0\u53d6HTML\u4e2d\u7684\u6570\u636e\u3002\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u5b89\u88c5BeautifulSoup\u548clxml\u89e3\u6790\u5668\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">pip install beautifulsoup4 lxml<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528BeautifulSoup\u89e3\u6790HTML\u5185\u5bb9\uff0c\u5e76\u63d0\u53d6\u6211\u4eec\u9700\u8981\u7684\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<p>soup = BeautifulSoup(html_content, &#39;lxml&#39;)<\/p>\n<p>results = soup.find_all(&#39;div&#39;, class_=&#39;result&#39;)<\/p>\n<p>for result in results:<\/p>\n<p>    title = result.find(&#39;h3&#39;).get_text()<\/p>\n<p>    link = result.find(&#39;a&#39;)[&#39;href&#39;]<\/p>\n<p>    summary = result.find(&#39;div&#39;, class_=&#39;c-abstract&#39;).get_text()<\/p>\n<p>    print(f&#39;Title: {title}\\nLink: {link}\\nSummary: {summary}\\n&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528BeautifulSoup\u89e3\u6790HTML\u5185\u5bb9\uff0c\u5e76\u627e\u5230\u6240\u6709\u5305\u542b\u641c\u7d22\u7ed3\u679c\u7684<code>div<\/code>\u6807\u7b7e\u3002\u7136\u540e\uff0c\u6211\u4eec\u63d0\u53d6\u6bcf\u4e2a\u641c\u7d22\u7ed3\u679c\u7684\u6807\u9898\u3001\u94fe\u63a5\u548c\u6458\u8981\uff0c\u5e76\u6253\u5370\u51fa\u6765\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u5229\u7528Selenium\u6a21\u62df\u7528\u6237\u64cd\u4f5c<\/h3>\n<\/p>\n<p><p>\u6709\u4e9b\u7f51\u9875\u4f7f\u7528JavaScript\u52a8\u6001\u52a0\u8f7d\u5185\u5bb9\uff0c\u7b80\u5355\u7684HTTP\u8bf7\u6c42\u65e0\u6cd5\u83b7\u53d6\u5b8c\u6574\u7684\u6570\u636e\u3002\u8fd9\u65f6\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528Selenium\u6a21\u62df\u7528\u6237\u64cd\u4f5c\uff0c\u52a0\u8f7d\u5b8c\u6574\u7684\u9875\u9762\u5185\u5bb9\u3002\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u5b89\u88c5Selenium\u548c\u6d4f\u89c8\u5668\u9a71\u52a8\uff08\u5982ChromeDriver\uff09\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">pip install selenium<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\u4e0b\u8f7d\u4e0e\u6d4f\u89c8\u5668\u7248\u672c\u5339\u914d\u7684ChromeDriver\uff0c\u5e76\u5c06\u5176\u8def\u5f84\u6dfb\u52a0\u5230\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\u4e2d\u3002\u4ee5\u4e0b\u662f\u4f7f\u7528Selenium\u83b7\u53d6\u767e\u5ea6\u641c\u7d22\u7ed3\u679c\u7684\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from selenium import webdriver<\/p>\n<p>from selenium.webdriver.common.keys import Keys<\/p>\n<p>driver = webdriver.Chrome()<\/p>\n<p>driver.get(&#39;https:\/\/www.baidu.com&#39;)<\/p>\n<p>search_box = driver.find_element_by_name(&#39;wd&#39;)<\/p>\n<p>search_box.send_keys(&#39;python&#39;)<\/p>\n<p>search_box.send_keys(Keys.RETURN)<\/p>\n<p>results = driver.find_elements_by_class_name(&#39;result&#39;)<\/p>\n<p>for result in results:<\/p>\n<p>    title = result.find_element_by_tag_name(&#39;h3&#39;).text<\/p>\n<p>    link = result.find_element_by_tag_name(&#39;a&#39;).get_attribute(&#39;href&#39;)<\/p>\n<p>    summary = result.find_element_by_class_name(&#39;c-abstract&#39;).text<\/p>\n<p>    print(f&#39;Title: {title}\\nLink: {link}\\nSummary: {summary}\\n&#39;)<\/p>\n<p>driver.quit()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528Selenium\u6253\u5f00\u767e\u5ea6\u9875\u9762\uff0c\u8f93\u5165\u641c\u7d22\u5173\u952e\u8bcd\u5e76\u63d0\u4ea4\u8868\u5355\u3002\u7136\u540e\uff0c\u6211\u4eec\u627e\u5230\u6240\u6709\u641c\u7d22\u7ed3\u679c\uff0c\u5e76\u63d0\u53d6\u6807\u9898\u3001\u94fe\u63a5\u548c\u6458\u8981\u3002\u6700\u540e\uff0c\u5173\u95ed\u6d4f\u89c8\u5668\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u9075\u5faa\u53cd\u722c\u866b\u7b56\u7565<\/h3>\n<\/p>\n<p><p>\u5728\u722c\u53d6\u7f51\u9875\u6570\u636e\u65f6\uff0c\u6211\u4eec\u9700\u8981\u9075\u5faa\u4e00\u4e9b\u53cd\u722c\u866b\u7b56\u7565\uff0c\u4ee5\u907f\u514d\u88ab\u5c01\u7981\u6216\u5bf9\u670d\u52a1\u5668\u9020\u6210\u8fc7\u5927\u8d1f\u62c5\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u89c1\u7684\u53cd\u722c\u866b\u7b56\u7565\uff1a<\/p>\n<\/p>\n<ol>\n<li><strong>\u8bbe\u7f6e\u5408\u7406\u7684\u8bf7\u6c42\u95f4\u9694<\/strong>\uff1a\u5728\u53d1\u9001\u591a\u4e2a\u8bf7\u6c42\u65f6\uff0c\u8bbe\u7f6e\u9002\u5f53\u7684\u65f6\u95f4\u95f4\u9694\uff0c\u907f\u514d\u9891\u7e41\u8bbf\u95ee\u670d\u52a1\u5668\u3002\u53ef\u4ee5\u4f7f\u7528<code>time.sleep()<\/code>\u51fd\u6570\u5b9e\u73b0\u8bf7\u6c42\u95f4\u9694\u3002<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">import time<\/p>\n<p>for url in urls:<\/p>\n<p>    response = requests.get(url, headers=headers)<\/p>\n<p>    if response.status_code == 200:<\/p>\n<p>        # \u5904\u7406\u54cd\u5e94\u5185\u5bb9<\/p>\n<p>        time.sleep(1)  # \u8bbe\u7f6e1\u79d2\u95f4\u9694<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u4f7f\u7528\u4e0d\u540c\u7684User-Agent<\/strong>\uff1a\u5728\u8bf7\u6c42\u5934\u4e2d\u8bbe\u7f6e\u4e0d\u540c\u7684User-Agent\uff0c\u4ee5\u6a21\u62df\u4e0d\u540c\u7684\u6d4f\u89c8\u5668\u8bf7\u6c42\u3002\u53ef\u4ee5\u4f7f\u7528<code>fake_useragent<\/code>\u5e93\u751f\u6210\u968f\u673aUser-Agent\u3002<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">from fake_useragent import UserAgent<\/p>\n<p>ua = UserAgent()<\/p>\n<p>headers = {&#39;User-Agent&#39;: ua.random}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"3\">\n<li><strong>\u4f7f\u7528\u4ee3\u7406\u670d\u52a1\u5668<\/strong>\uff1a\u901a\u8fc7\u4ee3\u7406\u670d\u52a1\u5668\u53d1\u9001\u8bf7\u6c42\uff0c\u53ef\u4ee5\u9690\u85cf\u771f\u5b9eIP\u5730\u5740\uff0c\u907f\u514d\u88ab\u5c01\u7981\u3002\u53ef\u4ee5\u4f7f\u7528<code>requests<\/code>\u5e93\u4e2d\u7684<code>proxies<\/code>\u53c2\u6570\u8bbe\u7f6e\u4ee3\u7406\u3002<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">proxies = {<\/p>\n<p>    &#39;http&#39;: &#39;http:\/\/proxy.example.com:8080&#39;,<\/p>\n<p>    &#39;https&#39;: &#39;https:\/\/proxy.example.com:8080&#39;<\/p>\n<p>}<\/p>\n<p>response = requests.get(url, headers=headers, proxies=proxies)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"4\">\n<li><strong>\u9075\u5faaRobots.txt\u534f\u8bae<\/strong>\uff1a\u5728\u722c\u53d6\u7f51\u7ad9\u524d\uff0c\u68c0\u67e5\u7f51\u7ad9\u7684<code>robots.txt<\/code>\u6587\u4ef6\uff0c\u4e86\u89e3\u54ea\u4e9b\u9875\u9762\u5141\u8bb8\u722c\u53d6\uff0c\u54ea\u4e9b\u9875\u9762\u7981\u6b62\u722c\u53d6\uff0c\u9075\u5faa\u7f51\u7ad9\u7684\u722c\u53d6\u89c4\u5219\u3002<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">import requests<\/p>\n<p>robots_url = &#39;https:\/\/www.baidu.com\/robots.txt&#39;<\/p>\n<p>response = requests.get(robots_url)<\/p>\n<p>print(response.text)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"5\">\n<li><strong>\u63a7\u5236\u5e76\u53d1\u8bf7\u6c42\u6570\u91cf<\/strong>\uff1a\u4f7f\u7528\u591a\u7ebf\u7a0b\u6216\u5f02\u6b65\u7f16\u7a0b\u65f6\uff0c\u63a7\u5236\u5e76\u53d1\u8bf7\u6c42\u7684\u6570\u91cf\uff0c\u907f\u514d\u5bf9\u670d\u52a1\u5668\u9020\u6210\u8fc7\u5927\u8d1f\u62c5\u3002\u53ef\u4ee5\u4f7f\u7528<code>threading<\/code>\u6a21\u5757\u6216<code>asyncio<\/code>\u5e93\u5b9e\u73b0\u5e76\u53d1\u8bf7\u6c42\u3002<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">import threading<\/p>\n<p>def fetch_page(url):<\/p>\n<p>    response = requests.get(url, headers=headers)<\/p>\n<p>    if response.status_code == 200:<\/p>\n<p>        # \u5904\u7406\u54cd\u5e94\u5185\u5bb9<\/p>\n<p>urls = [&#39;https:\/\/www.baidu.com\/s?wd=python&amp;page=&#39; + str(i) for i in range(1, 11)]<\/p>\n<p>threads = []<\/p>\n<p>for url in urls:<\/p>\n<p>    thread = threading.Thread(target=fetch_page, args=(url,))<\/p>\n<p>    threads.append(thread)<\/p>\n<p>    thread.start()<\/p>\n<p>for thread in threads:<\/p>\n<p>    thread.join()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u9075\u5faa\u8fd9\u4e9b\u53cd\u722c\u866b\u7b56\u7565\uff0c\u6211\u4eec\u53ef\u4ee5\u63d0\u9ad8\u722c\u53d6\u6548\u7387\uff0c\u907f\u514d\u88ab\u5c01\u7981\uff0c\u5e76\u4e14\u51cf\u5c11\u5bf9\u670d\u52a1\u5668\u7684\u5f71\u54cd\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u5904\u7406JavaScript\u52a8\u6001\u52a0\u8f7d\u5185\u5bb9<\/h3>\n<\/p>\n<p><p>\u6709\u4e9b\u7f51\u9875\u4f7f\u7528JavaScript\u52a8\u6001\u52a0\u8f7d\u5185\u5bb9\uff0c\u76f4\u63a5\u53d1\u9001HTTP\u8bf7\u6c42\u83b7\u53d6\u7684HTML\u5185\u5bb9\u53ef\u80fd\u4e0d\u5b8c\u6574\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528Selenium\u6a21\u62df\u6d4f\u89c8\u5668\u52a0\u8f7d\u9875\u9762\uff0c\u83b7\u53d6\u5b8c\u6574\u7684HTML\u5185\u5bb9\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u4f7f\u7528Selenium\u5904\u7406JavaScript\u52a8\u6001\u52a0\u8f7d\u5185\u5bb9\u7684\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from selenium import webdriver<\/p>\n<p>from selenium.webdriver.chrome.service import Service<\/p>\n<p>from selenium.webdriver.common.by import By<\/p>\n<p>from selenium.webdriver.support.ui import WebDriverWait<\/p>\n<p>from selenium.webdriver.support import expected_conditions as EC<\/p>\n<h2><strong>\u8bbe\u7f6eChromeDriver\u8def\u5f84<\/strong><\/h2>\n<p>service = Service(&#39;path\/to\/chromedriver&#39;)<\/p>\n<p>driver = webdriver.Chrome(service=service)<\/p>\n<h2><strong>\u6253\u5f00\u767e\u5ea6\u641c\u7d22\u9875\u9762<\/strong><\/h2>\n<p>driver.get(&#39;https:\/\/www.baidu.com&#39;)<\/p>\n<h2><strong>\u627e\u5230\u641c\u7d22\u6846\u5e76\u8f93\u5165\u5173\u952e\u8bcd<\/strong><\/h2>\n<p>search_box = driver.find_element(By.NAME, &#39;wd&#39;)<\/p>\n<p>search_box.send_keys(&#39;python&#39;)<\/p>\n<p>search_box.send_keys(Keys.RETURN)<\/p>\n<h2><strong>\u7b49\u5f85\u641c\u7d22\u7ed3\u679c\u52a0\u8f7d\u5b8c\u6210<\/strong><\/h2>\n<p>wait = WebDriverWait(driver, 10)<\/p>\n<p>wait.until(EC.presence_of_element_located((By.CLASS_NAME, &#39;result&#39;)))<\/p>\n<h2><strong>\u83b7\u53d6\u641c\u7d22\u7ed3\u679c<\/strong><\/h2>\n<p>results = driver.find_elements(By.CLASS_NAME, &#39;result&#39;)<\/p>\n<p>for result in results:<\/p>\n<p>    title = result.find_element(By.TAG_NAME, &#39;h3&#39;).text<\/p>\n<p>    link = result.find_element(By.TAG_NAME, &#39;a&#39;).get_attribute(&#39;href&#39;)<\/p>\n<p>    summary = result.find_element(By.CLASS_NAME, &#39;c-abstract&#39;).text<\/p>\n<p>    print(f&#39;Title: {title}\\nLink: {link}\\nSummary: {summary}\\n&#39;)<\/p>\n<h2><strong>\u5173\u95ed\u6d4f\u89c8\u5668<\/strong><\/h2>\n<p>driver.quit()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528Selenium\u6253\u5f00\u767e\u5ea6\u9875\u9762\uff0c\u8f93\u5165\u641c\u7d22\u5173\u952e\u8bcd\u5e76\u63d0\u4ea4\u8868\u5355\u3002\u7136\u540e\uff0c\u6211\u4eec\u7b49\u5f85\u641c\u7d22\u7ed3\u679c\u52a0\u8f7d\u5b8c\u6210\uff0c\u5e76\u63d0\u53d6\u6bcf\u4e2a\u641c\u7d22\u7ed3\u679c\u7684\u6807\u9898\u3001\u94fe\u63a5\u548c\u6458\u8981\u3002\u6700\u540e\uff0c\u5173\u95ed\u6d4f\u89c8\u5668\u3002<\/p>\n<\/p>\n<p><h3>\u516d\u3001\u5904\u7406\u9a8c\u8bc1\u7801\u548c\u767b\u5f55<\/h3>\n<\/p>\n<p><p>\u6709\u4e9b\u7f51\u7ad9\u5728\u8bbf\u95ee\u9891\u7387\u8fc7\u9ad8\u65f6\u4f1a\u5f39\u51fa\u9a8c\u8bc1\u7801\uff0c\u6216\u8005\u9700\u8981\u767b\u5f55\u624d\u80fd\u8bbf\u95ee\u6570\u636e\u3002\u5bf9\u4e8e\u9a8c\u8bc1\u7801\uff0c\u6211\u4eec\u53ef\u4ee5\u624b\u52a8\u8f93\u5165\u6216\u4f7f\u7528\u7b2c\u4e09\u65b9\u9a8c\u8bc1\u7801\u8bc6\u522b\u670d\u52a1\u3002\u5bf9\u4e8e\u767b\u5f55\uff0c\u53ef\u4ee5\u4f7f\u7528Selenium\u6a21\u62df\u767b\u5f55\u8fc7\u7a0b\uff0c\u83b7\u53d6\u767b\u5f55\u540e\u7684\u9875\u9762\u5185\u5bb9\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u4f7f\u7528Selenium\u5904\u7406\u767b\u5f55\u7684\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from selenium import webdriver<\/p>\n<p>from selenium.webdriver.chrome.service import Service<\/p>\n<p>from selenium.webdriver.common.by import By<\/p>\n<p>from selenium.webdriver.common.keys import Keys<\/p>\n<h2><strong>\u8bbe\u7f6eChromeDriver\u8def\u5f84<\/strong><\/h2>\n<p>service = Service(&#39;path\/to\/chromedriver&#39;)<\/p>\n<p>driver = webdriver.Chrome(service=service)<\/p>\n<h2><strong>\u6253\u5f00\u767e\u5ea6\u767b\u5f55\u9875\u9762<\/strong><\/h2>\n<p>driver.get(&#39;https:\/\/www.baidu.com&#39;)<\/p>\n<h2><strong>\u627e\u5230\u767b\u5f55\u6309\u94ae\u5e76\u70b9\u51fb<\/strong><\/h2>\n<p>login_button = driver.find_element(By.LINK_TEXT, &#39;\u767b\u5f55&#39;)<\/p>\n<p>login_button.click()<\/p>\n<h2><strong>\u5207\u6362\u5230\u767b\u5f55\u6846iframe<\/strong><\/h2>\n<p>driver.switch_to.frame(driver.find_element(By.ID, &#39;login_frame&#39;))<\/p>\n<h2><strong>\u8f93\u5165\u7528\u6237\u540d\u548c\u5bc6\u7801<\/strong><\/h2>\n<p>username = driver.find_element(By.NAME, &#39;username&#39;)<\/p>\n<p>password = driver.find_element(By.NAME, &#39;password&#39;)<\/p>\n<p>username.send_keys(&#39;your_username&#39;)<\/p>\n<p>password.send_keys(&#39;your_password&#39;)<\/p>\n<p>password.send_keys(Keys.RETURN)<\/p>\n<h2><strong>\u5207\u6362\u56de\u4e3b\u9875\u9762<\/strong><\/h2>\n<p>driver.switch_to.default_content()<\/p>\n<h2><strong>\u68c0\u67e5\u767b\u5f55\u662f\u5426\u6210\u529f<\/strong><\/h2>\n<p>if &#39;your_username&#39; in driver.page_source:<\/p>\n<p>    print(&#39;Login successful&#39;)<\/p>\n<p>else:<\/p>\n<p>    print(&#39;Login failed&#39;)<\/p>\n<h2><strong>\u5173\u95ed\u6d4f\u89c8\u5668<\/strong><\/h2>\n<p>driver.quit()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528Selenium\u6253\u5f00\u767e\u5ea6\u767b\u5f55\u9875\u9762\uff0c\u8f93\u5165\u7528\u6237\u540d\u548c\u5bc6\u7801\uff0c\u5e76\u63d0\u4ea4\u8868\u5355\u3002\u7136\u540e\uff0c\u6211\u4eec\u68c0\u67e5\u9875\u9762\u5185\u5bb9\uff0c\u786e\u8ba4\u767b\u5f55\u662f\u5426\u6210\u529f\u3002\u6210\u529f\u767b\u5f55\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u7ee7\u7eed\u722c\u53d6\u767b\u5f55\u540e\u7684\u9875\u9762\u5185\u5bb9\u3002<\/p>\n<\/p>\n<p><h3>\u4e03\u3001\u5b58\u50a8\u722c\u53d6\u7684\u6570\u636e<\/h3>\n<\/p>\n<p><p>\u722c\u53d6\u7684\u6570\u636e\u53ef\u4ee5\u5b58\u50a8\u5728\u4e0d\u540c\u7684\u5730\u65b9\uff0c\u5982\u6570\u636e\u5e93\u3001\u6587\u4ef6\u7b49\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u89c1\u7684\u5b58\u50a8\u65b9\u5f0f\uff1a<\/p>\n<\/p>\n<ol>\n<li><strong>\u5b58\u50a8\u5230CSV\u6587\u4ef6<\/strong>\uff1a<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">import csv<\/p>\n<p>with open(&#39;data.csv&#39;, &#39;w&#39;, newline=&#39;&#39;, encoding=&#39;utf-8&#39;) as csvfile:<\/p>\n<p>    fieldnames = [&#39;title&#39;, &#39;link&#39;, &#39;summary&#39;]<\/p>\n<p>    writer = csv.DictWriter(csvfile, fieldnames=fieldnames)<\/p>\n<p>    writer.writeheader()<\/p>\n<p>    for result in results:<\/p>\n<p>        writer.writerow({&#39;title&#39;: result[&#39;title&#39;], &#39;link&#39;: result[&#39;link&#39;], &#39;summary&#39;: result[&#39;summary&#39;]})<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u5b58\u50a8\u5230JSON\u6587\u4ef6<\/strong>\uff1a<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">import json<\/p>\n<p>with open(&#39;data.json&#39;, &#39;w&#39;, encoding=&#39;utf-8&#39;) as jsonfile:<\/p>\n<p>    json.dump(results, jsonfile, ensure_ascii=False, indent=4)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"3\">\n<li><strong>\u5b58\u50a8\u5230SQLite\u6570\u636e\u5e93<\/strong>\uff1a<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">import sqlite3<\/p>\n<p>conn = sqlite3.connect(&#39;data.db&#39;)<\/p>\n<p>c = conn.cursor()<\/p>\n<p>c.execute(&#39;&#39;&#39;CREATE TABLE IF NOT EXISTS results (title TEXT, link TEXT, summary TEXT)&#39;&#39;&#39;)<\/p>\n<p>for result in results:<\/p>\n<p>    c.execute(&#39;INSERT INTO results (title, link, summary) VALUES (?, ?, ?)&#39;, (result[&#39;title&#39;], result[&#39;link&#39;], result[&#39;summary&#39;]))<\/p>\n<p>conn.commit()<\/p>\n<p>conn.close()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"4\">\n<li><strong>\u5b58\u50a8\u5230MySQL\u6570\u636e\u5e93<\/strong>\uff1a<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">import mysql.connector<\/p>\n<p>conn = mysql.connector.connect(<\/p>\n<p>    host=&#39;localhost&#39;,<\/p>\n<p>    user=&#39;your_username&#39;,<\/p>\n<p>    password=&#39;your_password&#39;,<\/p>\n<p>    database=&#39;your_database&#39;<\/p>\n<p>)<\/p>\n<p>c = conn.cursor()<\/p>\n<p>c.execute(&#39;&#39;&#39;CREATE TABLE IF NOT EXISTS results (title VARCHAR(255), link VARCHAR(255), summary TEXT)&#39;&#39;&#39;)<\/p>\n<p>for result in results:<\/p>\n<p>    c.execute(&#39;INSERT INTO results (title, link, summary) VALUES (%s, %s, %s)&#39;, (result[&#39;title&#39;], result[&#39;link&#39;], result[&#39;summary&#39;]))<\/p>\n<p>conn.commit()<\/p>\n<p>conn.close()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u5b58\u50a8\u722c\u53d6\u7684\u6570\u636e\uff0c\u6211\u4eec\u53ef\u4ee5\u65b9\u4fbf\u5730\u8fdb\u884c\u540e\u7eed\u7684\u6570\u636e\u5206\u6790\u548c\u5904\u7406\u3002<\/p>\n<\/p>\n<p><h3>\u516b\u3001\u4f7f\u7528\u4ee3\u7406\u6c60\u8fdb\u884c\u722c\u53d6<\/h3>\n<\/p>\n<p><p>\u4e3a\u4e86\u9632\u6b62IP\u88ab\u5c01\u7981\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u4ee3\u7406\u6c60\u8fdb\u884c\u722c\u53d6\u3002\u4ee3\u7406\u6c60\u53ef\u4ee5\u81ea\u52a8\u5207\u6362\u4ee3\u7406IP\uff0c\u63d0\u9ad8\u722c\u53d6\u7684\u7a33\u5b9a\u6027\u548c\u6210\u529f\u7387\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u4ee3\u7406\u6c60\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import requests<\/p>\n<p>import random<\/p>\n<p>proxies = [<\/p>\n<p>    &#39;http:\/\/proxy1.example.com:8080&#39;,<\/p>\n<p>    &#39;http:\/\/proxy2.example.com:8080&#39;,<\/p>\n<p>    &#39;http:\/\/proxy3.example.com:8080&#39;<\/p>\n<p>]<\/p>\n<p>def get_random_proxy():<\/p>\n<p>    return {&#39;http&#39;: random.choice(proxies), &#39;https&#39;: random.choice(proxies)}<\/p>\n<p>url = &#39;https:\/\/www.baidu.com\/s?wd=python&#39;<\/p>\n<p>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>for _ in range(10):<\/p>\n<p>    proxy = get_random_proxy()<\/p>\n<p>    response = requests.get(url, headers=headers, proxies=proxy)<\/p>\n<p>    if response.status_code == 200:<\/p>\n<p>        html_content = response.text<\/p>\n<p>        # \u5904\u7406\u54cd\u5e94\u5185\u5bb9<\/p>\n<p>    else:<\/p>\n<p>        print(&#39;Failed to retrieve the page&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u5b9a\u4e49\u4e86\u4e00\u4e2a\u4ee3\u7406\u6c60\uff0c\u5e76\u968f\u673a\u9009\u62e9\u4e00\u4e2a\u4ee3\u7406IP\u53d1\u9001\u8bf7\u6c42\u3002\u901a\u8fc7\u4f7f\u7528\u4ee3\u7406\u6c60\uff0c\u6211\u4eec\u53ef\u4ee5\u964d\u4f4e\u88ab\u5c01\u7981\u7684\u98ce\u9669\uff0c\u63d0\u9ad8\u722c\u53d6\u7684\u6210\u529f\u7387\u3002<\/p>\n<\/p>\n<p><h3>\u4e5d\u3001\u5904\u7406\u5f02\u5e38\u548c\u9519\u8bef<\/h3>\n<\/p>\n<p><p>\u5728\u722c\u53d6\u8fc7\u7a0b\u4e2d\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u5404\u79cd\u5f02\u5e38\u548c\u9519\u8bef\u3002\u6211\u4eec\u9700\u8981\u5904\u7406\u8fd9\u4e9b\u5f02\u5e38\uff0c\u4fdd\u8bc1\u722c\u53d6\u7a0b\u5e8f\u7684\u7a33\u5b9a\u6027\u548c\u9c81\u68d2\u6027\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u89c1\u7684\u5f02\u5e38\u5904\u7406\u65b9\u6cd5\uff1a<\/p>\n<\/p>\n<ol>\n<li><strong>\u5904\u7406\u8bf7\u6c42\u5f02\u5e38<\/strong>\uff1a<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">import requests<\/p>\n<p>from requests.exceptions import RequestException<\/p>\n<p>url = &#39;https:\/\/www.baidu.com\/s?wd=python&#39;<\/p>\n<p>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>try:<\/p>\n<p>    response = requests.get(url, headers=headers)<\/p>\n<p>    response.raise_for_status()<\/p>\n<p>    html_content = response.text<\/p>\n<p>except RequestException as e:<\/p>\n<p>    print(f&#39;Request failed: {e}&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u5904\u7406\u89e3\u6790\u5f02\u5e38<\/strong>\uff1a<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">from bs4 import BeautifulSoup<\/p>\n<p>try:<\/p>\n<p>    soup = BeautifulSoup(html_content, &#39;lxml&#39;)<\/p>\n<p>    results = soup.find_all(&#39;div&#39;, class_=&#39;result&#39;)<\/p>\n<p>except Exception as e:<\/p>\n<p>    print(f&#39;Failed to parse HTML: {e}&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"3\">\n<li><strong>\u5904\u7406Selenium\u5f02\u5e38<\/strong>\uff1a<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">from selenium import webdriver<\/p>\n<p>from selenium.common.exceptions import NoSuchElementException, TimeoutException<\/p>\n<p>try:<\/p>\n<p>    driver = webdriver.Chrome()<\/p>\n<p>    driver.get(&#39;https:\/\/www.baidu.com&#39;)<\/p>\n<p>    search_box = driver.find_element(By.NAME, &#39;wd&#39;)<\/p>\n<p>    search_box.send_keys(&#39;python&#39;)<\/p>\n<p>    search_box.send_keys(Keys.RETURN)<\/p>\n<p>    results = driver.find_elements(By.CLASS_NAME, &#39;result&#39;)<\/p>\n<p>except NoSuchElementException as e:<\/p>\n<p>    print(f&#39;Element not found: {e}&#39;)<\/p>\n<p>except TimeoutException as e:<\/p>\n<p>    print(f&#39;Timeout: {e}&#39;)<\/p>\n<p>finally:<\/p>\n<p>    driver.quit()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u5904\u7406\u5f02\u5e38\u548c\u9519\u8bef\uff0c\u6211\u4eec\u53ef\u4ee5\u63d0\u9ad8\u722c\u53d6\u7a0b\u5e8f\u7684\u7a33\u5b9a\u6027\uff0c\u4fdd\u8bc1\u6570\u636e\u722c\u53d6\u7684\u8fde\u7eed\u6027\u548c\u5b8c\u6574\u6027\u3002<\/p>\n<\/p>\n<p><h3>\u5341\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u672c\u6587\u8be6\u7ec6\u4ecb\u7ecd\u4e86\u5982\u4f55\u4f7f\u7528Python\u5728\u767e\u5ea6\u722c\u53d6\u6570\u636e\u7684\u6b65\u9aa4\u548c\u65b9\u6cd5\uff0c\u5305\u62ec\u901a\u8fc7\u53d1\u9001HTTP\u8bf7\u6c42\u83b7\u53d6\u7f51\u9875\u5185\u5bb9\u3001\u4f7f\u7528BeautifulSoup\u89e3\u6790HTML\u3001\u5229\u7528Selenium\u6a21\u62df\u7528\u6237\u64cd\u4f5c\u3001\u9075\u5faa\u53cd\u722c\u866b\u7b56\u7565\u3001\u5904\u7406JavaScript\u52a8\u6001\u52a0\u8f7d\u5185\u5bb9\u3001\u5904\u7406\u9a8c\u8bc1\u7801\u548c\u767b\u5f55\u3001\u5b58\u50a8\u722c\u53d6\u7684\u6570\u636e\u3001\u4f7f\u7528\u4ee3\u7406\u6c60\u8fdb\u884c\u722c\u53d6\u4ee5\u53ca\u5904\u7406\u5f02\u5e38\u548c\u9519\u8bef\u3002\u901a\u8fc7\u638c\u63e1\u8fd9\u4e9b\u6280\u5de7\u548c\u65b9\u6cd5\uff0c\u6211\u4eec\u53ef\u4ee5\u9ad8\u6548\u3001\u7a33\u5b9a\u5730\u722c\u53d6\u767e\u5ea6\u4e0a\u7684\u6570\u636e\uff0c\u4e3a\u6570\u636e\u5206\u6790\u548c\u5e94\u7528\u63d0\u4f9b\u6709\u529b\u7684\u652f\u6301\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u4f7f\u7528Python\u722c\u53d6\u767e\u5ea6\u7684\u6570\u636e\uff1f<\/strong><br \/>\u4f7f\u7528Python\u722c\u53d6\u767e\u5ea6\u6570\u636e\u7684\u6b65\u9aa4\u5305\u62ec\u5b89\u88c5\u5fc5\u8981\u7684\u5e93\uff08\u5982requests\u548cBeautifulSoup\uff09\uff0c\u7f16\u5199\u4ee3\u7801\u53d1\u8d77HTTP\u8bf7\u6c42\u83b7\u53d6\u7f51\u9875\u5185\u5bb9\uff0c\u5e76\u89e3\u6790HTML\u7ed3\u6784\u63d0\u53d6\u6240\u9700\u6570\u636e\u3002\u9700\u8981\u786e\u4fdd\u9075\u5b88\u767e\u5ea6\u7684\u722c\u866b\u534f\u8bae\uff0c\u907f\u514d\u5bf9\u670d\u52a1\u5668\u9020\u6210\u8d1f\u62c5\u3002<\/p>\n<p><strong>\u5728\u722c\u53d6\u767e\u5ea6\u6570\u636e\u65f6\u9700\u8981\u6ce8\u610f\u54ea\u4e9b\u6cd5\u5f8b\u548c\u9053\u5fb7\u95ee\u9898\uff1f<\/strong><br \/>\u5728\u722c\u53d6\u6570\u636e\u65f6\uff0c\u5e94\u9075\u5faa\u7f51\u7ad9\u7684robots.txt\u6587\u4ef6\u4e2d\u7684\u89c4\u5b9a\uff0c\u5e76\u5c0a\u91cd\u7248\u6743\u548c\u9690\u79c1\u3002\u907f\u514d\u5927\u89c4\u6a21\u722c\u53d6\u5bfc\u81f4\u670d\u52a1\u5668\u538b\u529b\u8fc7\u5927\uff0c\u786e\u4fdd\u4e0d\u4f1a\u4fb5\u72af\u4efb\u4f55\u7528\u6237\u6216\u516c\u53f8\u7684\u6743\u76ca\u3002<\/p>\n<p><strong>\u5982\u4f55\u5904\u7406\u722c\u53d6\u767e\u5ea6\u6570\u636e\u65f6\u53ef\u80fd\u9047\u5230\u7684\u53cd\u722c\u866b\u673a\u5236\uff1f<\/strong><br \/>\u767e\u5ea6\u53ef\u80fd\u4f1a\u5b9e\u65bd\u591a\u79cd\u53cd\u722c\u866b\u7b56\u7565\uff0c\u4f8b\u5982IP\u5c01\u7981\u3001\u9a8c\u8bc1\u7801\u7b49\u3002\u4e3a\u5e94\u5bf9\u8fd9\u4e9b\u95ee\u9898\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee3\u7406\u670d\u52a1\u5668\u3001\u8bbe\u7f6e\u8bf7\u6c42\u5934\u4f2a\u88c5\u6210\u6d4f\u89c8\u5668\u8bf7\u6c42\u3001\u4ee5\u53ca\u5728\u8bf7\u6c42\u4e4b\u95f4\u6dfb\u52a0\u968f\u673a\u5ef6\u65f6\u7b49\u65b9\u5f0f\uff0c\u5e2e\u52a9\u964d\u4f4e\u88ab\u8bc6\u522b\u4e3a\u722c\u866b\u7684\u98ce\u9669\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5982\u4f55\u4f7f\u7528Python\u5728\u767e\u5ea6\u722c\u53d6\u6570\u636e \u8981\u4f7f\u7528Python\u5728\u767e\u5ea6\u4e0a\u722c\u53d6\u6570\u636e\uff0c\u53ef\u4ee5\u4f7f\u7528requests\u3001Beauti [&hellip;]","protected":false},"author":3,"featured_media":1040867,"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\/1040862"}],"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=1040862"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1040862\/revisions"}],"predecessor-version":[{"id":1040870,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1040862\/revisions\/1040870"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1040867"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1040862"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1040862"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1040862"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}