from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
from bs4 import BeautifulSoup
driver = webdriver.PhantomJS()
#driver = webdriver.Firefox()
driver.get('http://global.ahnlab.com/site/securitycenter/securityinsight/securityInsightList.do')
driver.execute_script("getView('2218')")
html_source = driver.page_source
driver.quit()
soup = BeautifulSoup(html_source)
print(soup.h1.string)
當我使用Firefox()時,結果是[AhnLab將外觀置於第4個直年的RSAConference],我想要的。 但是當我使用PhanthomJS()時,結果是我不想要的[Security Insight]。execute_script()在python中無法使用phantomjs
如果我使用PhantomJS(),我無法得到我想要的結果? 我想用無頭瀏覽器得到第一個結果。
謝謝。
我的答案是否適合您? –