{"id":1104426,"date":"2025-01-08T16:20:33","date_gmt":"2025-01-08T08:20:33","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1104426.html"},"modified":"2025-01-08T16:20:35","modified_gmt":"2025-01-08T08:20:35","slug":"python%e5%a6%82%e4%bd%95%e7%88%ac%e5%8f%96%e7%bd%91%e9%a1%b5%e6%95%b0%e6%8d%ae%e5%ba%93","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1104426.html","title":{"rendered":"python\u5982\u4f55\u722c\u53d6\u7f51\u9875\u6570\u636e\u5e93"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25065807\/33f38717-adef-4675-ab73-6a22415363ea.webp\" alt=\"python\u5982\u4f55\u722c\u53d6\u7f51\u9875\u6570\u636e\u5e93\" \/><\/p>\n<p><p> <strong>Python\u722c\u53d6\u7f51\u9875\u6570\u636e\u5e93\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528requests\u5e93\u8fdb\u884c\u7f51\u9875\u8bf7\u6c42\u3001BeautifulSoup\u5e93\u8fdb\u884c\u7f51\u9875\u89e3\u6790\u3001pandas\u5e93\u8fdb\u884c\u6570\u636e\u5b58\u50a8\u3001SQLAlchemy\u5e93\u8fdb\u884c\u6570\u636e\u5e93\u64cd\u4f5c\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u4e00\u79cd\u65b9\u6cd5\u3002<\/strong><\/p>\n<\/p>\n<p><p>\u722c\u53d6\u7f51\u9875\u6570\u636e\u5e93\u7684\u6b65\u9aa4\u5305\u62ec\uff1a\u53d1\u9001HTTP\u8bf7\u6c42\u3001\u89e3\u6790\u7f51\u9875\u5185\u5bb9\u3001\u63d0\u53d6\u6570\u636e\u3001\u5b58\u50a8\u6570\u636e\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u63cf\u8ff0\u5982\u4f55\u4f7f\u7528Python\u5b9e\u73b0\u8fd9\u4e9b\u6b65\u9aa4\u3002<\/p>\n<\/p>\n<p><p><strong>\u4e00\u3001\u53d1\u9001HTTP\u8bf7\u6c42<\/strong><\/p>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u53d1\u9001HTTP\u8bf7\u6c42\u6765\u83b7\u53d6\u7f51\u9875\u5185\u5bb9\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528requests\u5e93\u6765\u5b9e\u73b0\u8fd9\u4e00\u70b9\u3002<\/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>else:<\/p>\n<p>    print(f&#39;F<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>led to retrieve the webpage. Status code: {response.status_code}&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528requests.get()\u65b9\u6cd5\u53d1\u9001GET\u8bf7\u6c42\uff0c\u5e76\u68c0\u67e5\u54cd\u5e94\u7684\u72b6\u6001\u7801\u3002\u5982\u679c\u72b6\u6001\u7801\u662f200\uff0c\u5219\u8868\u793a\u8bf7\u6c42\u6210\u529f\uff0c\u6211\u4eec\u53ef\u4ee5\u83b7\u53d6\u7f51\u9875\u5185\u5bb9\u3002<\/p>\n<\/p>\n<p><p><strong>\u4e8c\u3001\u89e3\u6790\u7f51\u9875\u5185\u5bb9<\/strong><\/p>\n<\/p>\n<p><p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u9700\u8981\u89e3\u6790\u7f51\u9875\u5185\u5bb9\uff0c\u4ee5\u4fbf\u63d0\u53d6\u6211\u4eec\u9700\u8981\u7684\u6570\u636e\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528BeautifulSoup\u5e93\u6765\u5b9e\u73b0\u8fd9\u4e00\u70b9\u3002<\/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><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528BeautifulSoup\u7c7b\u6765\u89e3\u6790\u7f51\u9875\u5185\u5bb9\uff0c\u5e76\u5c06\u5176\u8f6c\u6362\u4e3a\u4e00\u4e2aBeautifulSoup\u5bf9\u8c61\u3002<\/p>\n<\/p>\n<p><p><strong>\u4e09\u3001\u63d0\u53d6\u6570\u636e<\/strong><\/p>\n<\/p>\n<p><p>\u4e00\u65e6\u6211\u4eec\u89e3\u6790\u4e86\u7f51\u9875\u5185\u5bb9\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u4f7f\u7528BeautifulSoup\u63d0\u4f9b\u7684\u65b9\u6cd5\u6765\u63d0\u53d6\u6211\u4eec\u9700\u8981\u7684\u6570\u636e\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u793a\u4f8b\uff0c\u6f14\u793a\u5982\u4f55\u63d0\u53d6\u7f51\u9875\u4e0a\u7684\u6240\u6709\u94fe\u63a5\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">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<p><p>\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528find_all()\u65b9\u6cd5\u6765\u67e5\u627e\u6240\u6709\u7684<a>\u6807\u7b7e\uff0c\u5e76\u4f7f\u7528get()\u65b9\u6cd5\u6765\u83b7\u53d6\u6bcf\u4e2a\u6807\u7b7e\u7684href\u5c5e\u6027\u3002<\/p>\n<\/p>\n<p><p><strong>\u56db\u3001\u5b58\u50a8\u6570\u636e<\/strong><\/p>\n<\/p>\n<p><p>\u63d0\u53d6\u6570\u636e\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06\u5176\u5b58\u50a8\u5728\u6570\u636e\u5e93\u4e2d\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528pandas\u5e93\u5c06\u6570\u636e\u8f6c\u6362\u4e3aDataFrame\uff0c\u5e76\u4f7f\u7528SQLAlchemy\u5e93\u5c06\u5176\u5b58\u50a8\u5728\u6570\u636e\u5e93\u4e2d\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<p>from sqlalchemy import create_engine<\/p>\n<h2><strong>\u521b\u5efaDataFrame<\/strong><\/h2>\n<p>data = {&#39;links&#39;: [link.get(&#39;href&#39;) for link in links]}<\/p>\n<p>df = pd.DataFrame(data)<\/p>\n<h2><strong>\u5b58\u50a8\u6570\u636e\u5230SQLite\u6570\u636e\u5e93<\/strong><\/h2>\n<p>engine = create_engine(&#39;sqlite:\/\/\/web_data.db&#39;)<\/p>\n<p>df.to_sql(&#39;links&#39;, engine, if_exists=&#39;replace&#39;, index=False)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u9996\u5148\u521b\u5efa\u4e00\u4e2aDataFrame\uff0c\u7136\u540e\u4f7f\u7528SQLAlchemy\u7684create_engine()\u65b9\u6cd5\u521b\u5efa\u4e00\u4e2aSQLite\u6570\u636e\u5e93\u5f15\u64ce\uff0c\u5e76\u4f7f\u7528pandas\u7684to_sql()\u65b9\u6cd5\u5c06\u6570\u636e\u5b58\u50a8\u5728\u6570\u636e\u5e93\u4e2d\u3002<\/p>\n<\/p>\n<p><p><strong>\u4e94\u3001\u603b\u7ed3<\/strong><\/p>\n<\/p>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u6211\u4eec\u5b9e\u73b0\u4e86\u4f7f\u7528Python\u722c\u53d6\u7f51\u9875\u6570\u636e\u5e93\u7684\u8fc7\u7a0b\u3002\u603b\u7ed3\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<ol>\n<li><strong>\u53d1\u9001HTTP\u8bf7\u6c42<\/strong>\uff1a\u4f7f\u7528requests\u5e93\u53d1\u9001GET\u8bf7\u6c42\uff0c\u83b7\u53d6\u7f51\u9875\u5185\u5bb9\u3002<\/li>\n<li><strong>\u89e3\u6790\u7f51\u9875\u5185\u5bb9<\/strong>\uff1a\u4f7f\u7528BeautifulSoup\u5e93\u89e3\u6790\u7f51\u9875\u5185\u5bb9\uff0c\u8f6c\u6362\u4e3aBeautifulSoup\u5bf9\u8c61\u3002<\/li>\n<li><strong>\u63d0\u53d6\u6570\u636e<\/strong>\uff1a\u4f7f\u7528BeautifulSoup\u63d0\u4f9b\u7684\u65b9\u6cd5\u63d0\u53d6\u6211\u4eec\u9700\u8981\u7684\u6570\u636e\u3002<\/li>\n<li><strong>\u5b58\u50a8\u6570\u636e<\/strong>\uff1a\u4f7f\u7528pandas\u5e93\u5c06\u6570\u636e\u8f6c\u6362\u4e3aDataFrame\uff0c\u5e76\u4f7f\u7528SQLAlchemy\u5e93\u5c06\u5176\u5b58\u50a8\u5728\u6570\u636e\u5e93\u4e2d\u3002<\/li>\n<\/ol>\n<p><h3>\u8fdb\u4e00\u6b65\u6269\u5c55<\/h3>\n<\/p>\n<p><p><strong>\u4e00\u3001\u5904\u7406\u590d\u6742\u7f51\u9875<\/strong><\/p>\n<\/p>\n<p><p>\u5bf9\u4e8e\u4e00\u4e9b\u590d\u6742\u7684\u7f51\u9875\uff0c\u6211\u4eec\u53ef\u80fd\u9700\u8981\u4f7f\u7528Selenium\u5e93\u6765\u6a21\u62df\u6d4f\u89c8\u5668\u884c\u4e3a\uff0c\u4ee5\u4fbf\u52a0\u8f7d\u52a8\u6001\u5185\u5bb9\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from selenium import webdriver<\/p>\n<h2><strong>\u521d\u59cb\u5316WebDriver<\/strong><\/h2>\n<p>driver = webdriver.Chrome()<\/p>\n<p>driver.get(&#39;https:\/\/example.com&#39;)<\/p>\n<h2><strong>\u83b7\u53d6\u7f51\u9875\u5185\u5bb9<\/strong><\/h2>\n<p>html_content = driver.page_source<\/p>\n<p>driver.quit()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528Selenium\u5e93\u7684WebDriver\u7c7b\u6765\u542f\u52a8\u4e00\u4e2aChrome\u6d4f\u89c8\u5668\uff0c\u5e76\u83b7\u53d6\u7f51\u9875\u5185\u5bb9\u3002<\/p>\n<\/p>\n<p><p><strong>\u4e8c\u3001\u5904\u7406\u5206\u9875<\/strong><\/p>\n<\/p>\n<p><p>\u5bf9\u4e8e\u5305\u542b\u5206\u9875\u7684\u7f51\u9875\uff0c\u6211\u4eec\u9700\u8981\u7f16\u5199\u5faa\u73af\u6765\u5904\u7406\u6bcf\u4e00\u9875\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">page = 1<\/p>\n<p>while True:<\/p>\n<p>    url = f&#39;https:\/\/example.com\/page\/{page}&#39;<\/p>\n<p>    response = requests.get(url)<\/p>\n<p>    if response.status_code != 200:<\/p>\n<p>        break<\/p>\n<p>    html_content = response.text<\/p>\n<p>    soup = BeautifulSoup(html_content, &#39;html.parser&#39;)<\/p>\n<p>    # \u63d0\u53d6\u6570\u636e<\/p>\n<p>    page += 1<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u4e00\u4e2awhile\u5faa\u73af\u6765\u5904\u7406\u6bcf\u4e00\u9875\uff0c\u76f4\u5230\u8bf7\u6c42\u5931\u8d25\u4e3a\u6b62\u3002<\/p>\n<\/p>\n<p><p><strong>\u4e09\u3001\u6570\u636e\u6e05\u6d17<\/strong><\/p>\n<\/p>\n<p><p>\u5728\u63d0\u53d6\u6570\u636e\u540e\uff0c\u6211\u4eec\u53ef\u80fd\u9700\u8981\u5bf9\u6570\u636e\u8fdb\u884c\u6e05\u6d17\uff0c\u4ee5\u786e\u4fdd\u6570\u636e\u7684\u8d28\u91cf\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">df[&#39;links&#39;] = df[&#39;links&#39;].str.strip()<\/p>\n<p>df.drop_duplicates(inplace=True)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528pandas\u5e93\u7684str.strip()\u65b9\u6cd5\u53bb\u9664\u5b57\u7b26\u4e32\u4e2d\u7684\u7a7a\u767d\uff0c\u5e76\u4f7f\u7528drop_duplicates()\u65b9\u6cd5\u5220\u9664\u91cd\u590d\u9879\u3002<\/p>\n<\/p>\n<p><p><strong>\u56db\u3001\u9519\u8bef\u5904\u7406<\/strong><\/p>\n<\/p>\n<p><p>\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u6211\u4eec\u9700\u8981\u5904\u7406\u5404\u79cd\u53ef\u80fd\u7684\u9519\u8bef\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528try-except\u5757\u6765\u6355\u83b7\u548c\u5904\u7406\u9519\u8bef\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">try:<\/p>\n<p>    response = requests.get(url)<\/p>\n<p>    response.raise_for_status()<\/p>\n<p>except requests.exceptions.RequestException as e:<\/p>\n<p>    print(f&#39;Error: {e}&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528try-except\u5757\u6765\u6355\u83b7\u8bf7\u6c42\u9519\u8bef\uff0c\u5e76\u6253\u5370\u9519\u8bef\u4fe1\u606f\u3002<\/p>\n<\/p>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6269\u5c55\uff0c\u6211\u4eec\u53ef\u4ee5\u5904\u7406\u66f4\u590d\u6742\u7684\u7f51\u9875\u3001\u5206\u9875\u3001\u6570\u636e\u6e05\u6d17\u548c\u9519\u8bef\u5904\u7406\uff0c\u4f7f\u722c\u866b\u66f4\u52a0\u5065\u58ee\u548c\u7075\u6d3b\u3002<\/p>\n<\/p>\n<p><p><strong>\u4e94\u3001\u63d0\u9ad8\u722c\u866b\u6548\u7387<\/strong><\/p>\n<\/p>\n<p><p>\u63d0\u9ad8\u722c\u866b\u6548\u7387\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\u5b9e\u73b0\uff1a<\/p>\n<\/p>\n<ol>\n<li><strong>\u591a\u7ebf\u7a0b\u548c\u591a\u8fdb\u7a0b<\/strong>\uff1a\u4f7f\u7528\u591a\u7ebf\u7a0b\u6216\u591a\u8fdb\u7a0b\u6765\u5e76\u53d1\u6267\u884c\u722c\u866b\u4efb\u52a1\u3002<\/li>\n<li><strong>\u5f02\u6b65\u7f16\u7a0b<\/strong>\uff1a\u4f7f\u7528\u5f02\u6b65\u7f16\u7a0b\u6a21\u578b\u6765\u63d0\u9ad8\u722c\u866b\u7684\u5e76\u53d1\u80fd\u529b\u3002<\/li>\n<li><strong>\u7f13\u5b58<\/strong>\uff1a\u4f7f\u7528\u7f13\u5b58\u6280\u672f\u6765\u907f\u514d\u91cd\u590d\u8bf7\u6c42\u76f8\u540c\u7684\u7f51\u9875\u3002<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">from concurrent.futures import ThreadPoolExecutor<\/p>\n<p>def fetch_page(url):<\/p>\n<p>    response = requests.get(url)<\/p>\n<p>    return response.text<\/p>\n<p>urls = [&#39;https:\/\/example.com\/page\/1&#39;, &#39;https:\/\/example.com\/page\/2&#39;]<\/p>\n<p>with ThreadPoolExecutor(max_workers=4) as executor:<\/p>\n<p>    results = list(executor.map(fetch_page, urls))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528ThreadPoolExecutor\u7c7b\u6765\u521b\u5efa\u4e00\u4e2a\u7ebf\u7a0b\u6c60\uff0c\u5e76\u4f7f\u7528map()\u65b9\u6cd5\u6765\u5e76\u53d1\u6267\u884c\u722c\u866b\u4efb\u52a1\u3002<\/p>\n<\/p>\n<p><p><strong>\u516d\u3001\u5408\u6cd5\u6027\u548c\u9053\u5fb7\u6027<\/strong><\/p>\n<\/p>\n<p><p>\u5728\u8fdb\u884c\u7f51\u9875\u722c\u53d6\u65f6\uff0c\u6211\u4eec\u9700\u8981\u9075\u5b88\u7f51\u7ad9\u7684robots.txt\u6587\u4ef6\u548c\u76f8\u5173\u6cd5\u5f8b\u6cd5\u89c4\uff0c\u907f\u514d\u7ed9\u7f51\u7ad9\u5e26\u6765\u4e0d\u5fc5\u8981\u7684\u8d1f\u62c5\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">response = requests.get(&#39;https:\/\/example.com\/robots.txt&#39;)<\/p>\n<p>print(response.text)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u8bf7\u6c42\u7f51\u7ad9\u7684robots.txt\u6587\u4ef6\uff0c\u5e76\u6253\u5370\u5176\u5185\u5bb9\u3002<\/p>\n<\/p>\n<p><p><strong>\u603b\u7ed3<\/strong><\/p>\n<\/p>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\u548c\u6269\u5c55\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528Python\u722c\u53d6\u7f51\u9875\u6570\u636e\u5e93\uff0c\u5e76\u5904\u7406\u5404\u79cd\u590d\u6742\u60c5\u51b5\u3002\u5e0c\u671b\u8fd9\u4e9b\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\u8fdb\u884c\u7f51\u9875\u6570\u636e\u722c\u53d6\uff1f<\/strong><br \/>Python\u662f\u4e00\u79cd\u975e\u5e38\u6d41\u884c\u7684\u7f16\u7a0b\u8bed\u8a00\uff0c\u56e0\u5176\u4e30\u5bcc\u7684\u5e93\u548c\u7b80\u5355\u7684\u8bed\u6cd5\u800c\u53d7\u5230\u6570\u636e\u79d1\u5b66\u5bb6\u548c\u5f00\u53d1\u8005\u7684\u559c\u7231\u3002\u8981\u8fdb\u884c\u7f51\u9875\u6570\u636e\u722c\u53d6\uff0c\u901a\u5e38\u53ef\u4ee5\u4f7f\u7528<code>requests<\/code>\u5e93\u6765\u83b7\u53d6\u7f51\u9875\u5185\u5bb9\uff0c\u5e76\u7ed3\u5408<code>BeautifulSoup<\/code>\u6216<code>lxml<\/code>\u5e93\u6765\u89e3\u6790HTML\u3002\u5177\u4f53\u6b65\u9aa4\u5305\u62ec\u53d1\u9001\u8bf7\u6c42\u83b7\u53d6\u7f51\u9875\uff0c\u89e3\u6790HTML\u5185\u5bb9\uff0c\u63d0\u53d6\u9700\u8981\u7684\u6570\u636e\uff0c\u5e76\u5c06\u5176\u5b58\u50a8\u5230\u6570\u636e\u5e93\u6216\u6587\u4ef6\u4e2d\u3002<\/p>\n<p><strong>\u5728\u722c\u53d6\u7f51\u9875\u65f6\uff0c\u5982\u4f55\u5904\u7406\u53cd\u722c\u866b\u673a\u5236\uff1f<\/strong><br \/>\u8bb8\u591a\u7f51\u7ad9\u4e3a\u4e86\u4fdd\u62a4\u5176\u6570\u636e\uff0c\u4f1a\u5b9e\u65bd\u53cd\u722c\u866b\u673a\u5236\uff0c\u4f8b\u5982IP\u5c01\u7981\u3001\u8bf7\u6c42\u9891\u7387\u9650\u5236\u7b49\u3002\u4e3a\u4e86\u89c4\u907f\u8fd9\u4e9b\u9650\u5236\uff0c\u53ef\u4ee5\u91c7\u53d6\u4e00\u4e9b\u7b56\u7565\uff0c\u6bd4\u5982\u8bbe\u7f6e\u5408\u9002\u7684\u8bf7\u6c42\u95f4\u9694\u3001\u4f7f\u7528\u4ee3\u7406IP\u3001\u4f2a\u88c5\u8bf7\u6c42\u5934\u4fe1\u606f\u7b49\u3002\u6b64\u5916\uff0c\u4f7f\u7528\u52a8\u6001\u722c\u866b\u6846\u67b6\uff0c\u5982Selenium\uff0c\u53ef\u4ee5\u6a21\u62df\u771f\u5b9e\u7528\u6237\u7684\u64cd\u4f5c\uff0c\u4ece\u800c\u7ed5\u8fc7\u67d0\u4e9b\u57fa\u672c\u7684\u53cd\u722c\u866b\u63aa\u65bd\u3002<\/p>\n<p><strong>\u722c\u53d6\u540e\u7684\u6570\u636e\u5982\u4f55\u5b58\u50a8\u548c\u5904\u7406\uff1f<\/strong><br \/>\u722c\u53d6\u6570\u636e\u540e\uff0c\u5b58\u50a8\u548c\u5904\u7406\u662f\u4e00\u4e2a\u91cd\u8981\u73af\u8282\u3002\u53ef\u4ee5\u9009\u62e9\u5c06\u6570\u636e\u5b58\u50a8\u5728\u672c\u5730\u6587\u4ef6\uff08\u5982CSV\u3001JSON\uff09\u4e2d\uff0c\u6216\u4f7f\u7528\u6570\u636e\u5e93\uff08\u5982SQLite\u3001MySQL\u7b49\uff09\u8fdb\u884c\u5b58\u50a8\u3002\u5bf9\u4e8e\u5927\u89c4\u6a21\u6570\u636e\uff0c\u4f7f\u7528\u6570\u636e\u5e93\u53ef\u4ee5\u66f4\u65b9\u4fbf\u5730\u8fdb\u884c\u67e5\u8be2\u548c\u7ba1\u7406\u3002\u6b64\u5916\uff0c\u6570\u636e\u6e05\u6d17\u548c\u6574\u7406\u4e5f\u662f\u4e0d\u53ef\u6216\u7f3a\u7684\u6b65\u9aa4\uff0c\u4ee5\u786e\u4fdd\u6570\u636e\u7684\u8d28\u91cf\u548c\u53ef\u7528\u6027\u3002\u4f7f\u7528Pandas\u5e93\u53ef\u4ee5\u65b9\u4fbf\u5730\u8fdb\u884c\u6570\u636e\u5904\u7406\u548c\u5206\u6790\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Python\u722c\u53d6\u7f51\u9875\u6570\u636e\u5e93\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528requests\u5e93\u8fdb\u884c\u7f51\u9875\u8bf7\u6c42\u3001BeautifulSoup\u5e93\u8fdb\u884c\u7f51\u9875\u89e3\u6790 [&hellip;]","protected":false},"author":3,"featured_media":1104436,"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\/1104426"}],"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=1104426"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1104426\/revisions"}],"predecessor-version":[{"id":1104438,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1104426\/revisions\/1104438"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1104436"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1104426"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1104426"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1104426"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}