{"id":1074,"date":"2025-09-07T20:02:29","date_gmt":"2025-09-07T12:02:29","guid":{"rendered":"https:\/\/flighhai.cn\/?p=1074"},"modified":"2025-09-07T20:35:19","modified_gmt":"2025-09-07T12:35:19","slug":"%e5%95%86%e5%93%81%e6%8b%87%e6%8c%87%e5%9b%be","status":"publish","type":"post","link":"https:\/\/flighhai.cn\/?p=1074","title":{"rendered":"\u5546\u54c1\u62c7\u6307\u56fe"},"content":{"rendered":"<div>\n<div>from selenium import webdriver<\/div>\n<div>from selenium.webdriver.chrome.service import Service<\/div>\n<div>from selenium.webdriver.chrome.options import Options<\/div>\n<div>from bs4 import BeautifulSoup<\/div>\n<div>url = input(&#8220;\u8bf7\u8f93\u5165\u4f60\u8981\u8bbf\u95ee\u7684\u7f51\u5740: &#8220;)<\/div>\n<div>user_agent = &#8216;Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/137.0.0.0 Safari\/537.36&#8217;<\/div>\n<div>chrome_options = Options()<\/div>\n<div>chrome_options.add_argument(&#8220;&#8211;log-level=3&#8221;)<\/div>\n<div>chrome_options.add_argument(&#8220;&#8211;disable-logging&#8221;)<\/div>\n<div>chrome_options.add_argument(&#8220;&#8211;user-data-dir=C:\/selenium-profile&#8221;)<\/div>\n<div>chrome_options.add_argument(&#8220;&#8211;profile-directory=Default&#8221;)<\/div>\n<div>chrome_options.add_argument(f&#8217;user-agent={user_agent}&#8217;)<\/div>\n<div>driver = webdriver.Chrome(options=chrome_options)<\/div>\n<div>service = Service(r&#8221;C:\\Windows\\System32\\chromedriver.exe&#8221;, log_path=&#8221;NUL&#8221;)<\/div>\n<div>driver.get(url)<\/div>\n<div>html_source = driver.page_source<\/div>\n<div>with open(&#8220;rendered.html&#8221;, &#8220;w&#8221;, encoding=&#8221;utf-8&#8243;) as f:<\/div>\n<div>\u00a0 \u00a0 f.write(html_source)<\/div>\n<div>with open(&#8220;rendered.html&#8221;, &#8220;r&#8221;, encoding=&#8221;utf-8&#8243;) as f:<\/div>\n<div>\u00a0 \u00a0 soup = BeautifulSoup(f, &#8220;html.parser&#8221;)<\/div>\n<div>for img in (img for img in soup.find_all(&#8220;img&#8221;, src=True, placeholder=True, class_=True) if len(img.attrs) == 3):<\/div>\n<div>\u00a0 \u00a0 print(img[&#8220;src&#8221;])<\/div>\n<div>driver.quit()<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>from selenium import webdriver &hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"_links":{"self":[{"href":"https:\/\/flighhai.cn\/index.php?rest_route=\/wp\/v2\/posts\/1074"}],"collection":[{"href":"https:\/\/flighhai.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/flighhai.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/flighhai.cn\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/flighhai.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1074"}],"version-history":[{"count":3,"href":"https:\/\/flighhai.cn\/index.php?rest_route=\/wp\/v2\/posts\/1074\/revisions"}],"predecessor-version":[{"id":1078,"href":"https:\/\/flighhai.cn\/index.php?rest_route=\/wp\/v2\/posts\/1074\/revisions\/1078"}],"wp:attachment":[{"href":"https:\/\/flighhai.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1074"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/flighhai.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1074"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/flighhai.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1074"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}