我正在尝试使用代理废弃网站,但我被阻止/访问被拒绝。
这是我的代码:
this.webClient = new WebClient(BrowserVersion.FIREFOX_52, "190.132.233.13", 1212);
this.webClient.getCredentialsProvider().setCredentials(AuthScope.ANY, new NTCredentials("username", "password", "", ""));
HtmlPage page = this.webClient.getPage("http://htmlunit.sourceforge.net");
我也尝试过:
this.webClient = new WebClient(BrowserVersion.FIREFOX_52, "190.132.233.13", 1212);
System.setProperty("http.proxyHost", "190.132.233.13");
System.setProperty("http.proxyPort", "1212");
System.setProperty("java.net.useSystemProxies", "true");
this.webClient.getPage("http://htmlunit.sourceforge.net");
我正在尝试废弃的每个网站:
INFO: statusCode=[403] contentType=[text/html]
INFO: <!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>ERROR: WebSite Blocked / Access to Site Restricted</title>
<style type="text/css">
body { background-color: #000000; color: #FFFFFF; font-family: Verdana; }
</style>
</head>
<body>
<div id="titles">
<h1>ERROR</h1>
<h2>WebSite Blocked / Access to Site Restricted</h2>
</div>
<hr><br><br>
<div id="content">
<p>Sorry, the access to 'http://htmlunit.sourceforge.net/' is restricted.</p>
<p>To avoid abuse/spam, we only allow access to generic sites such as www.google.com</a>.</p>
<p>You'll be able to access http://htmlunit.sourceforge.net/ instantly by adding the domain to your whitelist in the control panel.</p>
<p>To add this domain to the whitelist, please read the getting started info on the control panel.</p>
<br>
<p>You may also request to remove this restriction and have full web access by contacting support.</p>
</div>
<hr>
<div id="footer">
</div>
</body>
<!-- squid ERR_ACCESS_DENIED -->
</html>
我不明白getCredentialsProvider函数的用途是什么。 谢谢您的帮助。我使用的代理是私人代理。