繁体   English   中英

无法通过代理隧道 - Jsoup

[英]Unable to tunnel through proxy - Jsoup

创建 HTTP 连接时出现以下异常。

2017-08-07 17:07:43,219 ERROR au.com.scraper.sites.ScraperSite - Exception in parsing Categories: Unable to tunnel through proxy. Proxy returns "HTTP/1.1 403 Forbidden" at line number 153
java.io.IOException: Unable to tunnel through proxy. Proxy returns "HTTP/1.1 403 Forbidden"
    at sun.net.www.protocol.http.HttpURLConnection.doTunneling(HttpURLConnection.java:2085)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:183)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:153)
    at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:563)
    at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:540)
    at org.jsoup.helper.HttpConnection.execute(HttpConnection.java:227)
    at org.jsoup.helper.HttpConnection.get(HttpConnection.java:216)
    at org.jsoup.Jsoup.parse(Jsoup.java:183)
    at au.com.scraper.sites.ScraperSite.getCategories(ScraperSite.java:127)
    at au.com.scraper.sites.AScraperSites.execute(AScraperSites.java:74)
    at au.com.scraper.Scraper.main(Scraper.java:88)

下面是我的代理配置。

Authenticator.setDefault(new ProxyAuthenticator("user_name", "password"));
System.setProperty("https.proxyHost", server);
System.setProperty("https.proxyPort", port);
System.setProperty("http.proxyHost", server);
System.setProperty("http.proxyPort", port);

下面是我的代理身份验证器类。

package au.com.scraper;
import java.net.Authenticator;
import java.net.PasswordAuthentication;
public class ProxyAuthenticator extends Authenticator
{
    public ProxyAuthenticator(String user, String password)
    {
        this.user = user;
        this.password = password;
    }
    protected PasswordAuthentication getPasswordAuthentication()
    {
        return new PasswordAuthentication(user, password.toCharArray());
    }
    private String user;
    private String password;
}

任何人都可以提出为什么会发生这个问题吗?

您的代理服务器可能会阻止该网址,当网址是本地地址并且您的代理服务器将阻止该地址时,我们可能会遇到此问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM