{"id":237,"date":"2022-02-18T13:33:57","date_gmt":"2022-02-18T05:33:57","guid":{"rendered":"http:\/\/blog.iichen.cn\/?p=237"},"modified":"2022-02-18T13:33:57","modified_gmt":"2022-02-18T05:33:57","slug":"python-selenium%e4%bd%bf%e7%94%a8%e8%ae%b0%e5%bd%95","status":"publish","type":"post","link":"https:\/\/iichen.cn\/?p=237","title":{"rendered":"Python-Selenium\u4f7f\u7528\u8bb0\u5f55"},"content":{"rendered":"<h3>(\u4e00) \u542f\u52a8\u6d4f\u89c8\u5668<\/h3>\n<h4>1. \u666e\u901a\u542f\u52a8\u65b9\u5f0f<\/h4>\n<pre><code class=\"language-python line-numbers\">#!\/usr\/bin\/python3\n# encoding:utf-8\nfrom selenium  import webdriver\n\n#\u542f\u52a8Firefox\u6d4f\u89c8\u5668\n#browser = webdriver.Firefox()\n#\u542f\u52a8IE\u6d4f\u89c8\u5668\n#browser = webdriver.Ie()\n#\u542f\u52a8Chrome\u6d4f\u89c8\u5668\n#\u6307\u5b9a\u9a71\u52a8\u65b9\u5f0f\u542f\u52a8\uff1awebdriver.Chrome(executable_path=\"D:\/\/chromedriver.exe\")\nbrowser = webdriver.Chrome()\nbrowser.get(\"http:\/\/www.baidu.com\")\n<\/code><\/pre>\n<h4>2. Headless\u542f\u52a8\u65b9\u5f0f<\/h4>\n<blockquote><p>\n  \u6d4f\u89c8\u5668\u7684\u65e0\u754c\u9762\u5f62\u6001\uff0c\u65e0\u9700\u6253\u5f00\u6d4f\u89c8\u5668\u5373\u53ef\u8fd0\u884c\uff0c\u6b64\u79cd\u65b9\u5f0f\u53eachrome60+\u7248\u672c\n<\/p><\/blockquote>\n<pre><code class=\"language-python line-numbers\">#!\/usr\/bin\/python3\n# encoding:utf-8\nfrom selenium import webdriver\n\nchrome_hless = webdriver.ChromeOptions()\n# \u4f7f\u7528headless\u65e0\u754c\u9762\u6d4f\u89c8\u5668\u6a21\u5f0f\nchrome_hless.add_argument('--headless') \nchrome_hless.add_argument('--disable-gpu') \n\n# \u542f\u52a8\u6d4f\u89c8\u5668\uff0c\u83b7\u53d6\u7f51\u9875\u6e90\u4ee3\u7801\nbrowser = webdriver.Chrome(chrome_options=chrome_hless)\nmainUrl = \"https:\/\/www.baidu.com\/\"\nbrowser.get(mainUrl)\nprint(browser.title)\nbrowser.quit()\n<\/code><\/pre>\n<h3>(\u4e8c) \u5143\u7d20\u5b9a\u4f4d<\/h3>\n<blockquote><p>\n  \u65b0\u7248\u7684\u5b9a\u4f4d\uff0c\u5c06\u6761\u4ef6\u9009\u62e9\u4f5c\u4e3a\u53c2\u6570\u4e86\u3002\u5982\uff1a<br \/>\n  find_element_by_id   => find_element(By.ID,&#8221;xxx&#8221;)<br \/>\n  xpath\u5b9a\u4f4d\u53ef\u4ee5\u7ed3\u5408\u6d4f\u89c8\u5668 xpath\u6269\u5c55\n<\/p><\/blockquote>\n<table>\n<thead>\n<tr>\n<th>\u5143\u7d20<\/th>\n<th>\u5b9a\u4f4d\u65b9\u5f0f<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>id<\/td>\n<td>find_element_by_id()<\/td>\n<\/tr>\n<tr>\n<td>name<\/td>\n<td>find_element_by_name()<\/td>\n<\/tr>\n<tr>\n<td>class<\/td>\n<td>find_element_by_class_name()<\/td>\n<\/tr>\n<tr>\n<td>link_text<\/td>\n<td>find_element_by_link_text(&#8220;\u5168\u90e8\u6587\u5b57\u5339\u914d&#8221;)<\/td>\n<\/tr>\n<tr>\n<td>partial_link_text<\/td>\n<td>find_element_by_partial_link_text(&#8220;\u90e8\u5206\u6587\u5b57\u5339\u914d&#8221;)<\/td>\n<\/tr>\n<tr>\n<td>tag<\/td>\n<td>find_element_by_tag_name()<\/td>\n<\/tr>\n<tr>\n<td>xpath<\/td>\n<td>find_element_by_xpath()<\/td>\n<\/tr>\n<tr>\n<td>css<\/td>\n<td>find_element_by_css_selector()<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>(\u4e09) selenium\u4e09\u79cd\u7b49\u5f85\u65b9\u5f0f<\/h3>\n<h4>1. \u5f3a\u5236\u7b49\u5f85<\/h4>\n<pre><code class=\"language-python line-numbers\">from selenium import webdriver\nimport time\ntime.sleep(3)\n<\/code><\/pre>\n<h4>2. \u9690\u6027\u7b49\u5f85<\/h4>\n<pre><code class=\"language-python line-numbers\"># \u6d4f\u89c8\u5668\u52a0\u8f7d\u5b8c\u6210\uff0c\u5373\u8fdb\u884c\u4e0b\u4e00\u6b65\u64cd\u4f5c\uff0c\u5982\u679c10\u79d2\u949f\u8fd8\u672a\u52a0\u8f7d\u5b8c\u6210\uff0c\u4e5f\u8fdb\u884c\u4e0b\u4e00\u6b65\u64cd\u4f5c\ndriver.implicitly_wait(10) \n<\/code><\/pre>\n<h4>3. \u663e\u6027\u7b49\u5f85<\/h4>\n<blockquote><p>\n  selenium.webdriver.support.wait.WebDriverWait\n<\/p><\/blockquote>\n<pre><code class=\"language-python line-numbers\">driver: \u4f20\u5165WebDriver\u5b9e\u4f8b\uff0c\u5373\u6211\u4eec\u4e0a\u4f8b\u4e2d\u7684driver\ntimeout: \u8d85\u65f6\u65f6\u95f4\uff0c\u7b49\u5f85\u7684\u6700\u957f\u65f6\u95f4\uff08\u540c\u65f6\u8981\u8003\u8651\u9690\u6027\u7b49\u5f85\u65f6\u95f4\uff09\npoll_frequency: \u8c03\u7528until\u6216until_not\u4e2d\u7684\u65b9\u6cd5\u7684\u95f4\u9694\u65f6\u95f4\uff0c\u9ed8\u8ba4\u662f0.5\u79d2\nignored_exceptions: \u5ffd\u7565\u7684\u5f02\u5e38\uff0c\u5982\u679c\u5728\u8c03\u7528until\u6216until_not\u7684\u8fc7\u7a0b\u4e2d\u629b\u51fa\u8fd9\u4e2a\u5143\u7ec4\u4e2d\u7684\u5f02\u5e38\uff0c\u5219\u4e0d\u4e2d\u65ad\u4ee3\u7801\uff0c\u7ee7\u7eed\u7b49\u5f85\uff0c\u5982\u679c\u629b\u51fa\u7684\u662f\u8fd9\u4e2a\u5143\u7ec4\u5916\u7684\u5f02\u5e38\uff0c\u5219\u4e2d\u65ad\u4ee3\u7801\uff0c\u629b\u51fa\u5f02\u5e38\u3002\u9ed8\u8ba4\u53ea\u6709NoSuchElementException\u3002\n<\/code><\/pre>\n<blockquote><p>\n  until\n<\/p><\/blockquote>\n<pre><code class=\"language-python line-numbers\">method: \u5728\u7b49\u5f85\u671f\u95f4\uff0c\u6bcf\u9694\u4e00\u6bb5\u65f6\u95f4\uff08__init__\u4e2d\u7684poll_frequency\uff09\u8c03\u7528\u8fd9\u4e2a\u4f20\u5165\u7684\u65b9\u6cd5\uff0c\u76f4\u5230\u8fd4\u56de\u503c\u4e0d\u662fFalse\nmessage: \u5982\u679c\u8d85\u65f6\uff0c\u629b\u51faTimeoutException\uff0c\u5c06message\u4f20\u5165\u5f02\u5e38\n<\/code><\/pre>\n<blockquote><p>\n  until_not\n<\/p><\/blockquote>\n<pre><code class=\"language-python line-numbers\">\u4e0euntil\u76f8\u53cd\uff0cuntil\u662f\u5f53\u67d0\u5143\u7d20\u51fa\u73b0\u6216\u4ec0\u4e48\u6761\u4ef6\u6210\u7acb\u5219\u7ee7\u7eed\u6267\u884c\uff0c\nuntil_not\u662f\u5f53\u67d0\u5143\u7d20\u6d88\u5931\u6216\u4ec0\u4e48\u6761\u4ef6\u4e0d\u6210\u7acb\u5219\u7ee7\u7eed\u6267\u884c\uff0c\u53c2\u6570\u4e5f\u76f8\u540c\uff0c\u4e0d\u518d\u8d58\u8ff0\u3002\n<\/code><\/pre>\n<blockquote><p>\n  WebDriverWait \u5e38\u7528\u65b9\u6cd5\u8868\n<\/p><\/blockquote>\n<table>\n<thead>\n<tr>\n<th>\u5bf9\u8c61<\/th>\n<th>\u52a8\u4f5c<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>title_is<\/td>\n<td>\u5224\u65ad\u5f53\u524d\u9875\u9762\u7684title\u662f\u5426\u5b8c\u5168\u5339\u914d<\/td>\n<\/tr>\n<tr>\n<td>title_contains<\/td>\n<td>\u5224\u65ad\u5f53\u524d\u9875\u9762\u7684title\u662f\u5426\u5305\u542b\u9884\u671f\u5b57\u7b26\u4e32<\/td>\n<\/tr>\n<tr>\n<td>presence_of_element_located<\/td>\n<td>\u5224\u65ad\u67d0\u4e2a\u5143\u7d20\u662f\u5426\u88ab\u52a0\u5230\u4e86dom\u6811\u91cc\uff0c\u5e76\u4e0d\u4ee3\u8868\u8be5\u5143\u7d20\u4e00\u5b9a\u53ef\u89c1<\/td>\n<\/tr>\n<tr>\n<td>visibility_of_element_located<\/td>\n<td>\u5224\u65ad\u67d0\u4e2a\u5143\u7d20\u662f\u5426\u53ef\u89c1.\u53ef\u89c1\u4ee3\u8868\u5143\u7d20\u975e\u9690\u85cf\uff0c\u5e76\u4e14\u5143\u7d20\u7684\u5bbd\u548c\u9ad8\u90fd\u4e0d\u7b49\u4e8e0<\/td>\n<\/tr>\n<tr>\n<td>visibility_of<\/td>\n<td>\u8ddf\u4e0a\u9762\u7684\u65b9\u6cd5\u505a\u4e00\u6837\u7684\u4e8b\u60c5\uff0c\u53ea\u662f\u4e0a\u9762\u7684\u65b9\u6cd5\u8981\u4f20\u5165locator\uff0c\u8fd9\u4e2a\u65b9\u6cd5\u76f4\u63a5\u4f20\u5b9a\u4f4d\u5230\u7684element\u5c31\u597d\u4e86<\/td>\n<\/tr>\n<tr>\n<td>presence_of_all_elements_located<\/td>\n<td>\u5224\u65ad\u662f\u5426\u81f3\u5c11\u67091\u4e2a\u5143\u7d20\u5b58\u5728\u4e8edom\u6811\u4e2d\u3002\u4e3e\u4e2a\u4f8b\u5b50\uff0c\u5982\u679c\u9875\u9762\u4e0a\u6709n\u4e2a\u5143\u7d20\u7684class\u90fd\u662f&#8217;column-md-3&#8217;\uff0c\u90a3\u4e48\u53ea\u8981\u67091\u4e2a\u5143\u7d20\u5b58\u5728\uff0c\u8fd9\u4e2a\u65b9\u6cd5\u5c31\u8fd4\u56deTrue<\/td>\n<\/tr>\n<tr>\n<td>text_to_be_present_in_element<\/td>\n<td>\u5224\u65ad\u67d0\u4e2a\u5143\u7d20\u4e2d\u7684text\u662f\u5426\u5305\u542b\u4e86\u9884\u671f\u7684\u5b57\u7b26\u4e32<\/td>\n<\/tr>\n<tr>\n<td>text_to_be_present_in_element_value<\/td>\n<td>\u5224\u65ad\u67d0\u4e2a\u5143\u7d20\u4e2d\u7684value\u5c5e\u6027\u662f\u5426\u5305\u542b\u4e86\u9884\u671f\u7684\u5b57\u7b26\u4e32<\/td>\n<\/tr>\n<tr>\n<td>frame_to_be_available_and_switch_to_it<\/td>\n<td>\u5224\u65ad\u8be5frame\u662f\u5426\u53ef\u4ee5switch\u8fdb\u53bb\uff0c\u5982\u679c\u53ef\u4ee5\u7684\u8bdd\uff0c\u8fd4\u56deTrue\u5e76\u4e14switch\u8fdb\u53bb\uff0c\u5426\u5219\u8fd4\u56deFalse<\/td>\n<\/tr>\n<tr>\n<td>invisibility_of_element_located<\/td>\n<td>\u5224\u65ad\u67d0\u4e2a\u5143\u7d20\u4e2d\u662f\u5426\u4e0d\u5b58\u5728\u4e8edom\u6811\u6216\u4e0d\u53ef\u89c1<\/td>\n<\/tr>\n<tr>\n<td>element_to_be_clickable<\/td>\n<td>\u5224\u65ad\u67d0\u4e2a\u5143\u7d20\u4e2d\u662f\u5426\u53ef\u89c1\u5e76\u4e14\u662fenable\u7684\uff0c\u8fd9\u6837\u7684\u8bdd\u624d\u53ebclickable<\/td>\n<\/tr>\n<tr>\n<td>staleness_of<\/td>\n<td>\u7b49\u67d0\u4e2a\u5143\u7d20\u4ecedom\u6811\u4e2d\u79fb\u9664\uff0c\u6ce8\u610f\uff0c\u8fd9\u4e2a\u65b9\u6cd5\u4e5f\u662f\u8fd4\u56deTrue\u6216False<\/td>\n<\/tr>\n<tr>\n<td>element_to_be_selected<\/td>\n<td>\u5224\u65ad\u67d0\u4e2a\u5143\u7d20\u662f\u5426\u88ab\u9009\u4e2d\u4e86,\u4e00\u822c\u7528\u5728\u4e0b\u62c9\u5217\u8868<\/td>\n<\/tr>\n<tr>\n<td>element_selection_state_to_be<\/td>\n<td>\u5224\u65ad\u67d0\u4e2a\u5143\u7d20\u7684\u9009\u4e2d\u72b6\u6001\u662f\u5426\u7b26\u5408\u9884\u671f<\/td>\n<\/tr>\n<tr>\n<td>element_located_selection_state_to_be<\/td>\n<td>\u8ddf\u4e0a\u9762\u7684\u65b9\u6cd5\u4f5c\u7528\u4e00\u6837\uff0c\u53ea\u662f\u4e0a\u9762\u7684\u65b9\u6cd5\u4f20\u5165\u5b9a\u4f4d\u5230\u7684element\uff0c\u800c\u8fd9\u4e2a\u65b9\u6cd5\u4f20\u5165locator<\/td>\n<\/tr>\n<tr>\n<td>alert_is_present<\/td>\n<td>\u5224\u65ad\u9875\u9762\u4e0a\u662f\u5426\u5b58\u5728alert<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<blockquote><p>\n  \u5b9e\u4f8b\uff1a\n<\/p><\/blockquote>\n<pre><code class=\"language-python line-numbers\">#coding=utf-8\n#coding=utf-8\nfrom selenium import webdriver\nfrom selenium.webdriver.common.by import By\nfrom selenium.webdriver.support import expected_conditions as EC\nfrom selenium.webdriver.support.wait import WebDriverWait\n\nbase_url = \"http:\/\/www.baidu.com\"\ndriver = webdriver.Chrome()\ndriver.implicitly_wait(5)\n'''\u9690\u5f0f\u7b49\u5f85\u548c\u663e\u793a\u7b49\u5f85\u90fd\u5b58\u5728\u65f6\uff0c\u8d85\u65f6\u65f6\u95f4\u53d6\u4e8c\u8005\u4e2d\u6700\u5927\u7684'''\nlocator = (By.ID,'kw')\ndriver.get(base_url)\n\n'''\u5224\u65adtitle\u662f\u5426\u5b58\u5728,\u8fd4\u56de\u5e03\u5c14\u503c'''\nWebDriverWait(driver,10).until(EC.title_is(u\"\u767e\u5ea6\u4e00\u4e0b\uff0c\u4f60\u5c31\u77e5\u9053\"))\nif WebDriverWait(driver,10).until(EC.title_is(u\"\u767e\u5ea6\u4e00\u4e0b\uff0c\u4f60\u5c31\u77e5\u9053\")) :\n    print(\"\u5df2\u627e\u5230\u6807\u9898\u767e\u5ea6\u4e00\u4e0b\uff0c\u4f60\u5c31\u77e5\u9053\")\nWebDriverWait(driver,10).until(EC.title_contains(u\"\u767e\u5ea6\u4e00\u4e0b\"))\n\n'''\u5224\u65ad\u67d0\u4e2a\u5143\u7d20\u662f\u5426\u88ab\u52a0\u5230\u4e86dom\u6811\u91cc\uff0c\u5e76\u4e0d\u4ee3\u8868\u8be5\u5143\u7d20\u4e00\u5b9a\u53ef\u89c1\uff0c\u5982\u679c\u5b9a\u4f4d\u5230\u5c31\u8fd4\u56deWebElement'''\nsrk = WebDriverWait(driver,10).until(EC.presence_of_element_located((By.ID,'kw')))\n#\u767e\u5ea6\u8f93\u5165\u6846\uff0c\u8f93\u5165selenim\nsrk.send_keys(\"selenim\")\n\n'''\u5224\u65ad\u67d0\u4e2a\u5143\u7d20\u662f\u5426\u88ab\u6dfb\u52a0\u5230\u4e86dom\u91cc\u5e76\u4e14\u53ef\u89c1\uff0c\u53ef\u89c1\u4ee3\u8868\u5143\u7d20\u53ef\u663e\u793a\u4e14\u5bbd\u548c\u9ad8\u90fd\u5927\u4e8e0'''\nWebDriverWait(driver,10).until(EC.visibility_of_element_located((By.ID,'su')))\n\n'''\u5224\u65ad\u5143\u7d20\u662f\u5426\u53ef\u89c1\uff0c\u5982\u679c\u53ef\u89c1\u5c31\u8fd4\u56de\u8fd9\u4e2a\u5143\u7d20WebElement'''\nWebDriverWait(driver,10).until(EC.visibility_of(driver.find_element(by=By.ID,value='kw')))\n\n'''\u5224\u65ad\u662f\u5426\u81f3\u5c11\u67091\u4e2a\u5143\u7d20\u5b58\u5728\u4e8edom\u6811\u4e2d\uff0c\u5982\u679c\u5b9a\u4f4d\u5230\u5c31\u8fd4\u56deWebElement\u5217\u8868'''\nWebDriverWait(driver,10).until(EC.presence_of_all_elements_located((By.CSS_SELECTOR,'.mnav')))\n\n'''\u5224\u65ad\u662f\u5426\u81f3\u5c11\u6709\u4e00\u4e2a\u5143\u7d20\u5728\u9875\u9762\u4e2d\u53ef\u89c1\uff0c\u5982\u679c\u5b9a\u4f4d\u5230\u5c31\u8fd4\u56deWebElement\u5217\u8868'''\nWebDriverWait(driver,10).until(EC.visibility_of_any_elements_located((By.CSS_SELECTOR,'.mnav')))\n\n'''\u5224\u65ad\u6307\u5b9a\u7684\u5143\u7d20\u4e2d\u662f\u5426\u5305\u542b\u4e86\u9884\u671f\u7684\u5b57\u7b26\u4e32\uff0c\u8fd4\u56de\u5e03\u5c14\u503c'''\nWebDriverWait(driver,10).until(EC.text_to_be_present_in_element((By.XPATH,\"\/\/*[@id='u1']\/a[8]\"),u'\u8bbe\u7f6e'))\n\n'''\u5224\u65ad\u6307\u5b9a\u5143\u7d20\u7684\u5c5e\u6027\u503c\u4e2d\u662f\u5426\u5305\u542b\u4e86\u9884\u671f\u7684\u5b57\u7b26\u4e32\uff0c\u8fd4\u56de\u5e03\u5c14\u503c'''\nWebDriverWait(driver,10).until(EC.text_to_be_present_in_element_value((By.CSS_SELECTOR,'#su'),u'\u767e\u5ea6\u4e00\u4e0b'))\n\n'''\u5224\u65ad\u8be5frame\u662f\u5426\u53ef\u4ee5switch\u8fdb\u53bb\uff0c\u5982\u679c\u53ef\u4ee5\u7684\u8bdd\uff0c\u8fd4\u56deTrue\u5e76\u4e14switch\u8fdb\u53bb\uff0c\u5426\u5219\u8fd4\u56deFalse'''\n#WebDriverWait(driver,10).until(EC.frame_to_be_available_and_switch_to_it(locator))\n#\u6ce8\u610f\u8fd9\u91cc\u5e76\u6ca1\u6709\u4e00\u4e2aframe\u53ef\u4ee5\u5207\u6362\u8fdb\u53bb\n\n'''\u5224\u65ad\u67d0\u4e2a\u5143\u7d20\u5728\u662f\u5426\u5b58\u5728\u4e8edom\u6216\u4e0d\u53ef\u89c1,\u5982\u679c\u53ef\u89c1\u8fd4\u56deFalse,\u4e0d\u53ef\u89c1\u8fd4\u56de\u8fd9\u4e2a\u5143\u7d20'''\nWebDriverWait(driver,10).until(EC.invisibility_of_element_located((By.CSS_SELECTOR,'#swfEveryCookieWrap')))\n#\u6ce8\u610f#swfEveryCookieWrap\u5728\u6b64\u9875\u9762\u4e2d\u662f\u4e00\u4e2a\u9690\u85cf\u7684\u5143\u7d20\n\n'''\u5224\u65ad\u67d0\u4e2a\u5143\u7d20\u4e2d\u662f\u5426\u53ef\u89c1\u5e76\u4e14\u662fenable\u7684\uff0c\u4ee3\u8868\u53ef\u70b9\u51fb'''\nWebDriverWait(driver,10).until(EC.element_to_be_clickable((By.XPATH,\"\/\/*[@id='u1']\/a[8]\"))).click()\ndriver.find_element_by_xpath(\"\/\/*[@id='wrapper']\/div[6]\/a[1]\").click()\n'''\u7b49\u5f85\u67d0\u4e2a\u5143\u7d20\u4ecedom\u6811\u4e2d\u79fb\u9664'''\n#WebDriverWait(driver,10).until(EC.element_to_be_clickable((By.XPATH,\"\/\/*[@id='wrapper']\/div[6]\/a[1]\"))).click()\n#WebDriverWait(driver,10).until(EC.staleness_of(driver.find_element(By.ID,'su')))\n#\u8fd9\u91cc\u6ca1\u6709\u627e\u5230\u5408\u9002\u7684\u4f8b\u5b50\n\n'''\u5224\u65ad\u67d0\u4e2a\u5143\u7d20\u662f\u5426\u88ab\u9009\u4e2d\u4e86,\u4e00\u822c\u7528\u5728\u4e0b\u62c9\u5217\u8868'''\nWebDriverWait(driver,10).until(EC.element_to_be_selected(driver.find_element(By.XPATH,\"\/\/*[@id='nr']\/option[1]\")))\n\n'''\u5224\u65ad\u67d0\u4e2a\u5143\u7d20\u7684\u9009\u4e2d\u72b6\u6001\u662f\u5426\u7b26\u5408\u9884\u671f'''\nWebDriverWait(driver,10).until(EC.element_selection_state_to_be(driver.find_element(By.XPATH,\"\/\/*[@id='nr']\/option[1]\"),True))\n\n'''\u5224\u65ad\u67d0\u4e2a\u5143\u7d20\u7684\u9009\u4e2d\u72b6\u6001\u662f\u5426\u7b26\u5408\u9884\u671f'''\nWebDriverWait(driver,10).until(EC.element_located_selection_state_to_be((By.XPATH,\"\/\/*[@id='nr']\/option[1]\"),True))\ndriver.find_element_by_xpath(\".\/\/*[@id='gxszButton']\/a[1]\").click()\n\n'''\u5224\u65ad\u9875\u9762\u4e0a\u662f\u5426\u5b58\u5728alert,\u5982\u679c\u6709\u5c31\u5207\u6362\u5230alert\u5e76\u8fd4\u56dealert\u7684\u5185\u5bb9'''\ninstance = WebDriverWait(driver,10).until(EC.alert_is_present())\nprint(instance.text)\ninstance.accept()\n\ndriver.close()\n<\/code><\/pre>\n<hr \/>\n<h3>(\u56db) \u6d4f\u89c8\u5668\u64cd\u4f5c<\/h3>\n<h4>1. \u5c06\u6d4f\u89c8\u5668\u6700\u5927\u5316\u663e\u793a<\/h4>\n<pre><code class=\"language-python line-numbers\">browser.maximize_window()\n<\/code><\/pre>\n<h4>2. \u5c06\u6d4f\u89c8\u5668\u6700\u5c0f\u5316\u663e\u793a<\/h4>\n<pre><code class=\"language-python line-numbers\">browser.minimize_window()\n<\/code><\/pre>\n<h4>3. \u8bbe\u7f6e\u6d4f\u89c8\u5668\u5bbd1366\u3001\u9ad8768\u663e\u793a<\/h4>\n<pre><code class=\"language-python line-numbers\">browser.set_window_size(1366, 768)\n<\/code><\/pre>\n<h4>4. \u6d4f\u89c8\u5668\u524d\u8fdb\u3001\u540e\u9000\u3001\u9000\u51fa\u3001\u5173\u95ed<\/h4>\n<pre><code class=\"language-python line-numbers\">browser.forword()#\u524d\u8fdb\nbrowser.back()#\u540e\u9000\nbrowser.quit()#\u9000\u51fa\nbrowser.close()#\u5173\u95ed\n<\/code><\/pre>\n<h3>(\u4e94) \u64cd\u4f5c\u5143\u7d20\u5bf9\u8c61<\/h3>\n<table>\n<thead>\n<tr>\n<th>\u5bf9\u8c61<\/th>\n<th>\u52a8\u4f5c<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>clear()<\/td>\n<td>\u6e05\u7a7a<\/td>\n<\/tr>\n<tr>\n<td>send_keys()<\/td>\n<td>\u952e\u76d8\u64cd\u4f5c<\/td>\n<\/tr>\n<tr>\n<td>click()<\/td>\n<td>\u70b9\u51fb<\/td>\n<\/tr>\n<tr>\n<td>submit()<\/td>\n<td>\u63d0\u4ea4<\/td>\n<\/tr>\n<tr>\n<td>text<\/td>\n<td>\u83b7\u53d6\u5bf9\u8c61\u6587\u672c<\/td>\n<\/tr>\n<tr>\n<td>get_attribute()<\/td>\n<td>\u83b7\u53d6\u5bf9\u8c61\u5c5e\u6027\u503c<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>(\u516d) \u952e\u76d8\u4e8b\u4ef6<\/h3>\n<table>\n<thead>\n<tr>\n<th>\u5bf9\u8c61<\/th>\n<th>\u52a8\u4f5c<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>send_keys(Keys.TAB)<\/td>\n<td>TAB<\/td>\n<\/tr>\n<tr>\n<td>send_keys(Keys.ENTER)<\/td>\n<td>\u56de\u8f66 |<\/td>\n<\/tr>\n<tr>\n<td>send_keys(Keys.F12)<\/td>\n<td>F12<\/td>\n<\/tr>\n<tr>\n<td>send_keys(Keys.CONTROL,&#8217;a&#8217;)<\/td>\n<td>ctrl+a<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>(\u4e03) \u9f20\u6807\u4e8b\u4ef6<\/h3>\n<table>\n<thead>\n<tr>\n<th>\u5bf9\u8c61<\/th>\n<th>\u52a8\u4f5c<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>click<\/td>\n<td>\u5355\u51fb<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td>context_click() | \u53f3\u51fb<\/td>\n<\/tr>\n<tr>\n<td>double_click()<\/td>\n<td>\u53cc\u51fb<\/td>\n<\/tr>\n<tr>\n<td>drag_and_drop()<\/td>\n<td>\u62d6\u52a8<\/td>\n<\/tr>\n<tr>\n<td>move_to_element()<\/td>\n<td>\u9f20\u6807\u60ac\u505c<\/td>\n<\/tr>\n<tr>\n<td>click_and_hold<\/td>\n<td>\u6309\u4e0b\u9f20\u6807\u5de6\u952e\u5728\u4e00\u4e2a\u5143\u7d20\u4e0a<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>(\u516b) \u591a\u5c42\u6846\u67b6\/\u5c42\u7ea7\u5b9a\u4f4d<\/h3>\n<pre><code class=\"language-python line-numbers\">#\u5148\u627e\u5230\u5230 ifrome1\uff08id = from1\uff09\nbrowser.switch_to_frame(\"from1\")\n<\/code><\/pre>\n<h3>(\u4e5d) Selenium\u901f\u67e5\u8868<\/h3>\n<table>\n<thead>\n<tr>\n<th>\u5f02\u5e38<\/th>\n<th>\u63cf\u8ff0<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>WebDriverException<\/td>\n<td>\u6240\u6709webdriver\u5f02\u5e38\u7684\u57fa\u7c7b\uff0c\u5f53\u6709\u5f02\u5e38\u4e14\u4e0d\u5c5e\u4e8e\u4e0b\u5217\u5f02\u5e38\u65f6\u629b\u51fa<\/td>\n<\/tr>\n<tr>\n<td>InvalidSwitchToTargetException<\/td>\n<td>\u4e0b\u9762\u4e24\u4e2a\u5f02\u5e38\u7684\u7236\u7c7b\uff0c\u5f53\u8981switch\u7684\u76ee\u6807\u4e0d\u5b58\u5728\u65f6\u629b\u51fa<\/td>\n<\/tr>\n<tr>\n<td>NoSuchFrameException<\/td>\n<td>\u5f53\u4f60\u60f3\u8981\u7528switch_to.frame()\u5207\u5165\u67d0\u4e2a\u4e0d\u5b58\u5728\u7684frame\u65f6\u629b\u51fa<\/td>\n<\/tr>\n<tr>\n<td>NoSuchWindowException<\/td>\n<td>\u5f53\u4f60\u60f3\u8981\u7528switch_to.window()\u5207\u5165\u67d0\u4e2a\u4e0d\u5b58\u5728\u7684window\u65f6\u629b\u51fa<\/td>\n<\/tr>\n<tr>\n<td>NoSuchElementException<\/td>\n<td>\u5143\u7d20\u4e0d\u5b58\u5728\uff0c\u4e00\u822c\u7531find_element\u4e0efind_elements\u629b\u51fa<\/td>\n<\/tr>\n<tr>\n<td>NoSuchAttributeException<\/td>\n<td>\u4e00\u822c\u4f60\u83b7\u53d6\u4e0d\u5b58\u5728\u7684\u5143\u7d20\u5c5e\u6027\u65f6\u629b\u51fa\uff0c\u8981\u6ce8\u610f\u6709\u4e9b\u5c5e\u6027\u5728\u4e0d\u540c\u6d4f\u89c8\u5668\u91cc\u662f\u6709\u4e0d\u540c\u7684\u5c5e\u6027\u540d\u7684<\/td>\n<\/tr>\n<tr>\n<td>StaleElementReferenceException<\/td>\n<td>\u6307\u5b9a\u7684\u5143\u7d20\u8fc7\u65f6\u4e86\uff0c\u4e0d\u5728\u73b0\u5728\u7684DOM\u6811\u91cc\u4e86\uff0c\u53ef\u80fd\u662f\u88ab\u5220\u9664\u4e86\u6216\u8005\u662f\u9875\u9762\u6216iframe\u5237\u65b0\u4e86<\/td>\n<\/tr>\n<tr>\n<td>UnexpectedAlertPresentException<\/td>\n<td>\u51fa\u73b0\u4e86\u610f\u6599\u4e4b\u5916\u7684alert\uff0c\u963b\u788d\u4e86\u6307\u4ee4\u7684\u6267\u884c\u65f6\u629b\u51fa<\/td>\n<\/tr>\n<tr>\n<td>NoAlertPresentException<\/td>\n<td>\u4f60\u60f3\u8981\u83b7\u53d6alert\uff0c\u4f46\u5b9e\u9645\u6ca1\u6709alert\u51fa\u73b0\u65f6\u629b\u51fa<\/td>\n<\/tr>\n<tr>\n<td>InvalidElementStateException<\/td>\n<td>\u4e0b\u9762\u4e24\u4e2a\u5f02\u5e38\u7684\u7236\u7c7b\uff0c\u5f53\u5143\u7d20\u72b6\u6001\u4e0d\u80fd\u8fdb\u884c\u60f3\u8981\u7684\u64cd\u4f5c\u65f6\u629b\u51fa<\/td>\n<\/tr>\n<tr>\n<td>ElementNotVisibleException<\/td>\n<td>\u5143\u7d20\u5b58\u5728\uff0c\u4f46\u662f\u4e0d\u53ef\u89c1\uff0c\u4e0d\u53ef\u4ee5\u4e0e\u4e4b\u4ea4\u4e92<\/td>\n<\/tr>\n<tr>\n<td>ElementNotSelectableException<\/td>\n<td>\u5f53\u4f60\u60f3\u8981\u9009\u62e9\u4e00\u4e2a\u4e0d\u53ef\u88ab\u9009\u62e9\u7684\u5143\u7d20\u65f6\u629b\u51fa<\/td>\n<\/tr>\n<tr>\n<td>InvalidSelectorException<\/td>\n<td>\u4e00\u822c\u5f53\u4f60xpath\u8bed\u6cd5\u9519\u8bef\u7684\u65f6\u5019\u629b\u51fa\u8fd9\u4e2a\u9519<\/td>\n<\/tr>\n<tr>\n<td>InvalidCookieDomainException<\/td>\n<td>\u5f53\u4f60\u60f3\u8981\u5728\u975e\u5f53\u524durl\u7684\u57df\u91cc\u6dfb\u52a0cookie\u65f6\u629b\u51fa<\/td>\n<\/tr>\n<tr>\n<td>UnableToSetCookieException<\/td>\n<td>\u5f53driver\u65e0\u6cd5\u6dfb\u52a0\u4e00\u4e2acookie\u65f6\u629b\u51fa<\/td>\n<\/tr>\n<tr>\n<td>TimeoutException<\/td>\n<td>\u5f53\u4e00\u4e2a\u6307\u4ee4\u5728\u8db3\u591f\u7684\u65f6\u95f4\u5185\u6ca1\u6709\u5b8c\u6210\u65f6\u629b\u51fa<\/td>\n<\/tr>\n<tr>\n<td>MoveTargetOutOfBoundsException<\/td>\n<td>actions\u7684move\u64cd\u4f5c\u65f6\u629b\u51fa\uff0c\u5c06\u76ee\u6807\u79fb\u52a8\u51fa\u4e86window\u4e4b\u5916<\/td>\n<\/tr>\n<tr>\n<td>UnexpectedTagNameException<\/td>\n<td>\u83b7\u53d6\u5230\u7684\u5143\u7d20\u6807\u7b7e\u4e0d\u7b26\u5408\u8981\u6c42\u65f6\u629b\u51fa\uff0c\u6bd4\u5982\u5b9e\u4f8b\u5316Select\uff0c\u4f60\u4f20\u5165\u4e86\u975eselect\u6807\u7b7e\u7684\u5143\u7d20\u65f6<\/td>\n<\/tr>\n<tr>\n<td>ImeNotAvailableException<\/td>\n<td>\u8f93\u5165\u6cd5\u4e0d\u652f\u6301\u7684\u65f6\u5019\u629b\u51fa\uff0c\u8fd9\u91cc\u4e24\u4e2a\u5f02\u5e38\u4e0d\u5e38\u89c1\uff0cime\u5f15\u64ce\u636e\u8bf4\u662f\u4ec5\u7528\u4e8elinux\u4e0b\u5bf9\u4e2d\u6587\/\u65e5\u6587\u652f\u6301\u7684\u65f6\u5019<\/td>\n<\/tr>\n<tr>\n<td>ImeActivationFailedException<\/td>\n<td>\u6fc0\u6d3b\u8f93\u5165\u6cd5\u5931\u8d25\u65f6\u629b\u51fa<\/td>\n<\/tr>\n<tr>\n<td>ErrorInResponseException<\/td>\n<td>\u4e0d\u5e38\u89c1\uff0cserver\u7aef\u51fa\u9519\u65f6\u53ef\u80fd\u4f1a\u629b\u51fa<\/td>\n<\/tr>\n<tr>\n<td>RemoteDriverServerException<\/td>\n<td>\u4e0d\u5e38\u89c1\uff0c\u597d\u50cf\u662f\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\u9a71\u52a8\u542f\u52a8\u6d4f\u89c8\u5668\u5931\u8d25\u7684\u65f6\u5019\u4f1a\u62a5\u8fd9\u4e2a\u9519<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>(\u4e00) \u542f\u52a8\u6d4f\u89c8\u5668 1. \u666e\u901a\u542f\u52a8\u65b9\u5f0f #!\/usr\/bin\/python3 # encoding:utf-8 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15,8],"tags":[],"class_list":["post-237","post","type-post","status-publish","format-standard","hentry","category-python","category-8"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Python-Selenium\u4f7f\u7528\u8bb0\u5f55 - IIchen<\/title>\n<meta name=\"description\" content=\"python selenium\u81ea\u52a8\u5316\u6d4b\u8bd5\u5e38\u7528\u65b9\u6cd5\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/iichen.cn\/?p=237\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python-Selenium\u4f7f\u7528\u8bb0\u5f55 - IIchen\" \/>\n<meta property=\"og:description\" content=\"python selenium\u81ea\u52a8\u5316\u6d4b\u8bd5\u5e38\u7528\u65b9\u6cd5\" \/>\n<meta property=\"og:url\" content=\"https:\/\/iichen.cn\/?p=237\" \/>\n<meta property=\"og:site_name\" content=\"IIchen\" \/>\n<meta property=\"article:published_time\" content=\"2022-02-18T05:33:57+00:00\" \/>\n<meta name=\"author\" content=\"iichen\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"iichen\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/iichen.cn\/?p=237#article\",\"isPartOf\":{\"@id\":\"https:\/\/iichen.cn\/?p=237\"},\"author\":{\"name\":\"iichen\",\"@id\":\"https:\/\/iichen.cn\/#\/schema\/person\/4a47edf85ab49841df9e8f6aee40b77c\"},\"headline\":\"Python-Selenium\u4f7f\u7528\u8bb0\u5f55\",\"datePublished\":\"2022-02-18T05:33:57+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/iichen.cn\/?p=237\"},\"wordCount\":266,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/iichen.cn\/#\/schema\/person\/4a47edf85ab49841df9e8f6aee40b77c\"},\"articleSection\":[\"Python\",\"\u7b14\u8bb0\"],\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/iichen.cn\/?p=237#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/iichen.cn\/?p=237\",\"url\":\"https:\/\/iichen.cn\/?p=237\",\"name\":\"Python-Selenium\u4f7f\u7528\u8bb0\u5f55 - IIchen\",\"isPartOf\":{\"@id\":\"https:\/\/iichen.cn\/#website\"},\"datePublished\":\"2022-02-18T05:33:57+00:00\",\"description\":\"python selenium\u81ea\u52a8\u5316\u6d4b\u8bd5\u5e38\u7528\u65b9\u6cd5\",\"breadcrumb\":{\"@id\":\"https:\/\/iichen.cn\/?p=237#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/iichen.cn\/?p=237\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/iichen.cn\/?p=237#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/iichen.cn\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python-Selenium\u4f7f\u7528\u8bb0\u5f55\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/iichen.cn\/#website\",\"url\":\"https:\/\/iichen.cn\/\",\"name\":\"IIchen\",\"description\":\"Just do it!\",\"publisher\":{\"@id\":\"https:\/\/iichen.cn\/#\/schema\/person\/4a47edf85ab49841df9e8f6aee40b77c\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/iichen.cn\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"zh-Hans\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/iichen.cn\/#\/schema\/person\/4a47edf85ab49841df9e8f6aee40b77c\",\"name\":\"iichen\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/iichen.cn\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/iichen.cn\/wp-content\/uploads\/2025\/01\/avatar.jpg\",\"contentUrl\":\"https:\/\/iichen.cn\/wp-content\/uploads\/2025\/01\/avatar.jpg\",\"width\":940,\"height\":940,\"caption\":\"iichen\"},\"logo\":{\"@id\":\"https:\/\/iichen.cn\/#\/schema\/person\/image\/\"},\"sameAs\":[\"https:\/\/www.iichen.cn\"],\"url\":\"https:\/\/iichen.cn\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python-Selenium\u4f7f\u7528\u8bb0\u5f55 - IIchen","description":"python selenium\u81ea\u52a8\u5316\u6d4b\u8bd5\u5e38\u7528\u65b9\u6cd5","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/iichen.cn\/?p=237","og_locale":"zh_CN","og_type":"article","og_title":"Python-Selenium\u4f7f\u7528\u8bb0\u5f55 - IIchen","og_description":"python selenium\u81ea\u52a8\u5316\u6d4b\u8bd5\u5e38\u7528\u65b9\u6cd5","og_url":"https:\/\/iichen.cn\/?p=237","og_site_name":"IIchen","article_published_time":"2022-02-18T05:33:57+00:00","author":"iichen","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"iichen","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/iichen.cn\/?p=237#article","isPartOf":{"@id":"https:\/\/iichen.cn\/?p=237"},"author":{"name":"iichen","@id":"https:\/\/iichen.cn\/#\/schema\/person\/4a47edf85ab49841df9e8f6aee40b77c"},"headline":"Python-Selenium\u4f7f\u7528\u8bb0\u5f55","datePublished":"2022-02-18T05:33:57+00:00","mainEntityOfPage":{"@id":"https:\/\/iichen.cn\/?p=237"},"wordCount":266,"commentCount":0,"publisher":{"@id":"https:\/\/iichen.cn\/#\/schema\/person\/4a47edf85ab49841df9e8f6aee40b77c"},"articleSection":["Python","\u7b14\u8bb0"],"inLanguage":"zh-Hans","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/iichen.cn\/?p=237#respond"]}]},{"@type":"WebPage","@id":"https:\/\/iichen.cn\/?p=237","url":"https:\/\/iichen.cn\/?p=237","name":"Python-Selenium\u4f7f\u7528\u8bb0\u5f55 - IIchen","isPartOf":{"@id":"https:\/\/iichen.cn\/#website"},"datePublished":"2022-02-18T05:33:57+00:00","description":"python selenium\u81ea\u52a8\u5316\u6d4b\u8bd5\u5e38\u7528\u65b9\u6cd5","breadcrumb":{"@id":"https:\/\/iichen.cn\/?p=237#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/iichen.cn\/?p=237"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/iichen.cn\/?p=237#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/iichen.cn\/"},{"@type":"ListItem","position":2,"name":"Python-Selenium\u4f7f\u7528\u8bb0\u5f55"}]},{"@type":"WebSite","@id":"https:\/\/iichen.cn\/#website","url":"https:\/\/iichen.cn\/","name":"IIchen","description":"Just do it!","publisher":{"@id":"https:\/\/iichen.cn\/#\/schema\/person\/4a47edf85ab49841df9e8f6aee40b77c"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/iichen.cn\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"zh-Hans"},{"@type":["Person","Organization"],"@id":"https:\/\/iichen.cn\/#\/schema\/person\/4a47edf85ab49841df9e8f6aee40b77c","name":"iichen","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/iichen.cn\/#\/schema\/person\/image\/","url":"https:\/\/iichen.cn\/wp-content\/uploads\/2025\/01\/avatar.jpg","contentUrl":"https:\/\/iichen.cn\/wp-content\/uploads\/2025\/01\/avatar.jpg","width":940,"height":940,"caption":"iichen"},"logo":{"@id":"https:\/\/iichen.cn\/#\/schema\/person\/image\/"},"sameAs":["https:\/\/www.iichen.cn"],"url":"https:\/\/iichen.cn\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/iichen.cn\/index.php?rest_route=\/wp\/v2\/posts\/237","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/iichen.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/iichen.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/iichen.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/iichen.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=237"}],"version-history":[{"count":0,"href":"https:\/\/iichen.cn\/index.php?rest_route=\/wp\/v2\/posts\/237\/revisions"}],"wp:attachment":[{"href":"https:\/\/iichen.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=237"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/iichen.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=237"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/iichen.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=237"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}