获取重定向的请求

时间:2019-03-27 14:52:55

标签: java selenium

Getnada有一个API-https://getnada.com/api/v1/inboxes/ {email-id}。我正在尝试使用此API进行电子邮件验证,但是,我没有得到响应,而是重定向到其他一些网页。

这是我的代码:

    public Getnada(WebDriver driver, String testCaseId) {
        super(driver, testCaseId);
    }

    public void getnadaJSON(){

        String https_url = "https://getnada.com/api/v1/inboxes/ducazyx@getnada.com";
        URL url;

        try {
            url = new URL(https_url);
            HttpsURLConnection con = (HttpsURLConnection) url.openConnection();           

            SSLSocketFactory sslsocketfactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
            con.setSSLSocketFactory(sslsocketfactory);

            InputStream in = new BufferedInputStream(con.getInputStream());

            String result = IOUtils.toString(in, "UTF-8");

            System.out.println(result);

            in.close();
            con.disconnect();

        }catch (Exception e){
            System.out.println(e);
        }
    }

这是我得到的错误:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Notification: Found</title>
</head>
<body>
<h1>This Page Cannot Be Displayed</h1>
<hr>
<p>
The page (&nbsp;https://getnada.com/api/v1/inboxes/ducazyx@getnada.com&nbsp;)
is being redirected to (&nbsp;http://10.175.231.148:11000/75eun.pl?Time=28%2FFeb%2F2019%3A20%3A12%3A40%20%2B0000&#038;ID=959724547&#038;Client_IP=10.137.92.76&#038;User=-&#038;Site=getnada.com&#038;URI=api%2Fv1%2Finboxes%ducazyx@getnada.com&#038;Status_Code=403&#038;Decision_Tag=BLOCK_WEBCAT_12-DefaultGroup-Java_Execution-NONE-NONE-NONE-NONE&#038;URL_Cat=Web-based%20Email&#038;WBRS=-3.0&#038;DVS_Verdict=-&#038;DVS_ThreatName=-&#038;Time_Based=0&#038;Reauth_URL=- ).
</p>
<p>
If you are not automatically redirected to the new address,
click here: (&nbsp;<a href="http://10.175.231.148:11000/75eun.pl?Time=28%2FFeb%2F2019%3A20%3A12%3A40%20%2B0000&ID=959724547&Client_IP=10.137.92.76&User=-&Site=getnada.com&URI=api%2Fv1%2Finboxes%ducazyx@getnada.com&#038;Status_Code=403&#038;Decision_Tag=BLOCK_WEBCAT_12-DefaultGroup-Java_Execution-NONE-NONE-NONE-NONE&#038;URL_Cat=Web-based%20Email&#038;WBRS=-3.0&#038;DVS_Verdict=-&#038;DVS_ThreatName=-&#038;Time_Based=0&#038;Reauth_URL=-">http://10.175.231.148:11000/75eun.pl?Time=28%2FFeb%2F2019%3A20%3A12%3A40%20%2B0000&#038;ID=959724547&#038;Client_IP=10.137.92.76&#038;User=-&#038;Site=getnada.com&#038;URI=api%2Fv1%2Finboxes%ducazyx@getnada.com&#038;Status_Code=403&#038;Decision_Tag=BLOCK_WEBCAT_12-DefaultGroup-Java_Execution-NONE-NONE-NONE-NONE&#038;URL_Cat=Web-based%20Email&#038;WBRS=-3.0&#038;DVS_Verdict=-&#038;DVS_ThreatName=-&#038;Time_Based=0&#038;Reauth_URL=-</a> ).
</p>
<p>
If you have questions, or feel this is an error, please contact
your organization's network administrator 
and provide the codes shown below.
</p>
<hr>
<table>
  <tr valign="top">
   <td valign="top" width="10%">Notification&nbsp;codes:&nbsp;</td>
   <td valign="top" class="code" width="90%">(1, FOUND, http://10.175.231.148:11000/75eun.pl?Time=28%2FFeb%2F2019%3A20%3A12%3A40%20%2B0000&#038;ID=959724547&#038;Client_IP=10.137.92.76&#038;User=-&#038;Site=getnada.com&#038;URI=api%2Fv1%2Finboxes%ducazyx@getnada.com&#038;Status_Code=403&#038;Decision_Tag=BLOCK_WEBCAT_12-DefaultGroup-Java_Execution-NONE-NONE-NONE-NONE&#038;URL_Cat=Web-based%20Email&#038;WBRS=-3.0&#038;DVS_Verdict=-&#038;DVS_ThreatName=-&#038;Time_Based=0&#038;Reauth_URL=-, https://getnada.com/api/v1/inboxes/ducazyx@getnada.com)</td>
  </tr>
</table>
</body>
</html>

在此错误消息中,我注意到url中看起来像是空格。我觉得这就是问题所在。

0 个答案:

没有答案