Pythonを使ってSeleniumでこのページにログインしたいです。ただし、ブラウザーに表示されるページは、HTML に記述されているページとは異なります。Firefox または Chrome Web ドライバーは同じ結果を取得します。
chromedriver = "./chromedriver"
os.environ["webdriver.chrome.driver"] = chromedriver
driver = webdriver.Chrome(chromedriver)
# OR
#driver = webdriver.Firefox()
driver.get('http://www.anb.org/login.htmlurl=%2Farticles%2Fhome.html&ip=94.112.189.79&nocookie=0')
# get screenshot of page
driver.get_screenshot_as_file('./01.png')
#get source code of page
print driver.page_source
画像の掲載はお断りしておりますが、ブラウザで表示されるページと全く同じ画像です。
ドライバーからの HTML コード:
<html><head>
<title>American National Biography Online</title>
<script>
document.write ("<FRAMESET ROWS=\"103,*\" FRAMEBORDER=0 BORDER=0 FRAMESPACING=0>\n");
document.write (" <FRAME SRC=\"top-home.html\" MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING=NO>\n");
if (location.search) {
var url = unescape (location.search);
url = (new String(url)).substring(1);
if (url.indexOf ("&") == -1) {
document.write (" <FRAME SRC=\"" + url + "\" MARGINWIDTH=0 MARGINHEIGHT=0>\n");
} else {
document.write (" <FRAME SRC=\"main-home.html" + location.search + "\" MARGINWIDTH=0 MARGINHEIGHT=0>\n");
}
}
else
document.write (" <FRAME SRC=\"main-home.html\" NAME=atop MARGINWIDTH=0 MARGINHEIGHT=0>\n");
document.write ("</FRAMESET>\n");
</script></head>
<frameset rows="103,*" frameborder="0" border="0" framespacing="0">
<frame src="top-home.html" marginwidth="0" marginheight="0" scrolling="NO">
<frame src="main-home.html?url=%2Farticles%2Fbrowse.html&ip=94.112.189.79&nocookie=0" marginwidth="0" marginheight="0">
</frameset>
<noframes>
</noframes>
</html>
ご覧のとおり、HTML と画像は一致しません。
多分問題はフレームにありますか?
私の構成:
osx 10.8.5
python 2.7.5
chrome browser 28.0.1500.71
firefox browser 24.0
最新の chrome/firefox Web ドライバーをインストールしましたが、バージョンを見つける方法が本当にわかりません。