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)
Run Code Online (Sandbox Code Playgroud)
当我使用Firefox()时,结果是我想要的[AhnLab连续第四年参加RSA会议。但是,当我使用PhanthomJS()时,结果是我不需要的[Security Insight]。
如果使用PhantomJS(),则无法获得所需的结果?我想使用无头浏览器获得第一个结果。
谢谢。