Python请求模块 - 绕过ADF环回脚本来访问网站

时间:2015-06-18 19:31:55

标签: python python-requests

我尝试使用Python的请求模块访问网站,但我一直被重定向到另一个页面。我是新手,所以我不知道从哪里开始解决这个问题。

我的代码是:

import requests
r = requests.get('https://swiftlink.enbridge.com/portal/')
print r.text

但是,不是在该页面上打印文本,而是从以下开始输出:

    <html lang="en-US"><head><script>
/*
** Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
*/

/**
 * This is the loopback script to process the url before the real page loads. It introduces
 * a separate round trip. During this first roundtrip, we currently do two things: 
 * - check the url hash portion, this is for the PPR Navigation. 
 * - do the new window detection
 * the above two are both controled by parameters in web.xml
 * 
 * Since it's very lightweight, so the network latency is the only impact. 
 * 
 * here are the list of will-pass-in parameters (these will replace the param in this whole
 * pattern: 
 *        viewIdLength                           view Id length (characters), 
 *        loopbackIdParam                        loopback Id param name, 
 *        loopbackId                             loopback Id,
 *        loopbackIdParamMatchExpr               loopback Id match expression, 
 *        windowModeIdParam                      window mode param name, 
 *        windowModeParamMatchExpr               window mode match expression, 
 *        clientWindowIdParam                    client window Id param name, 
 *        clientWindowIdParamMatchExpr           client window Id match expression, 
 *        windowId                               window Id, 
 *        initPageLaunch                         initPageLaunch, 
 *        enableNewWindowDetect                  whether we want to enable new window detection
 *        jsessionId                             session Id that needs to be appended to the redirect URL
 *        enablePPRNav                           whether we want to enable PPR Navigation
 *
 */

经过一段谷歌搜索,我发现我被重定向到了一个Oracle ADF环回脚本页面,但我还没有找到解决方法。我已经尝试过禁止在我的代码中重定向,但这只是让我看到页面,说明我正在寻找的页面已暂时移动。我知道我使用的网址是有效的,因为它会把我带到正确的页面。

2 个答案:

答案 0 :(得分:0)

虽然不是您问题的直接答案。请记住,HTTP是客户端服务器协议,客户端请求数据,服务器响应所述数据,指示需要重定向或标记错误。 HTTP服务器没有义务响应请求的数据。

我注意到网址中的协议是https。我不熟悉请求模块,但您可能需要检查它是否正确处理SSL套接字包装,因为这可能是错误的来源。

答案 1 :(得分:0)

ADF页面需要其他参数。因此,您需要在第一次调用中 解压缩 ,然后在新请求中 追加 ,以查看页。

这是一篇关于如何配置Jmeter的文章,它显示了所有需要的参数。

Configuring Jmeter