urllib2 JavaScript 重定向问题
import urllib2,urllib
data = urllib.urlencode({"username" : "usr", "password" : "pass", "lang" : "eng", "usertype" : "cashier", "submit" : "Enter"})
req = urllib2.Request("https://website/index.php", data)
opener = urllib2.build_opener()
response = opener.open(req)
the_page = response.read()
print the_page
输出:
<script type="text/javascript">window.location.href = "/h383/list.php";</script>
所以我想访问list.php,有什么建议吗?
import urllib2,urllib
data = urllib.urlencode({"username" : "usr", "password" : "pass", "lang" : "eng", "usertype" : "cashier", "submit" : "Enter"})
req = urllib2.Request("https://website/index.php", data)
opener = urllib2.build_opener()
response = opener.open(req)
the_page = response.read()
print the_page
OUTPUT:
<script type="text/javascript">window.location.href = "/h383/list.php";</script>
So I want to reach list.php any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,尝试向网站管理员进行关于优雅降级和网络标准的严厉教训。
如果失败,那么您最终有两个选择:
window
和window.location
对象,并捕获对其href
的赋值代码>属性。 (优点:这将允许 JS 构建的 URL 工作,并且是相当面向未来的。缺点:这可能是过度设计,并且不是一个简单的任务。)First, try delivering a stern lecture to the webmaster about graceful degradation and web standards.
If that fails, then you ultimately have two options:
window
andwindow.location
objects, and catching the assignment to itshref
property. (Pros: This will allow for JS-built URLs to work, and is fairly future-proof. Cons: This is probably over-engineering, and won't be a simple task.)