Python selenium调用phantomjs问题

鼻涕虫de皮皮 2016-07-04 04:46:19
使用selenium调用火狐,谷歌浏览器都可以实现js的跳转,但是使用phantomjs抓取的内容却是一个js跳转方法。很奇怪为什么这条js没有执行,一般来说即使js执行失败也应该有异常之类的啊。
以下是抓取到的js页面内容:
<html><head>
<script type="text/javascript">
window.onload = function() {
// Parse the tracking code from cookies.
var trk = "sentinel_org_block";
var cookies = document.cookie.split("; ");
for (var i = 0; i < cookies.length; ++i) {
if ((cookies[i].indexOf("trkCode=") == 0) && (cookies[i].length > 8)) {
trk = cookies[i].substring(8);
}
}

// Get the protocol for the redirect url.
var protocol = "http:";
if (window.location.protocol == "https:") {
protocol = "https:";
} else {
// If "sl" cookie is set, redirect to https.
for (var i = 0; i < cookies.length; ++i) {
if ((cookies[i].indexOf("sl=") == 0) && (cookies[i].length > 3)) {
window.location.href = "https:" + window.location.href.substring(window.location.protocol.length);
return;
}
}
}

// Get the new domain. For touch.www.linkedin.com or tablet.www.linkedin.com
// we strip "touch." and "tablet.". For international domains such as
// fr.linkedin.com, we convert it to www.linkedin.com
var domain = location.host;
if (domain.substr(0, 6) == "touch.") {
domain = domain.substr(6);
} else if (domain.substr(0, 7) == "tablet.") {
domain = domain.substr(7);
} else if (domain.charAt(2) == ".") {
domain = "www" + domain.substr(2);
}

window.location.href = "https://" + domain + "/uas/login?trk=" + trk + "&session_redirect=" +
encodeURIComponent(protocol + "//" + domain +
window.location.href.substr(window.location.href.search(window.location.host) +
window.location.host.length));
}
</script>
</head><body>
</body></html>
...全文
212 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
鼻涕虫de皮皮 2016-07-05
  • 打赏
  • 举报
回复
自己顶,

37,743

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • WuKongSecurity@BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧