每当我编译时,我都会得到这个:
线程“main”中的异常 java.io.IOException:服务器返回 HTTP
响应代码:403 对于 URL:链接
sun.net.www.protocol.http.HttpURLConnection.getInputStream0(未知
来源)于
sun.net.www.protocol.http.HttpURLConnection.getInputStream(未知
来源)位于 java.net.URL.openStream(来源未知)位于
读取数据.aaa.main(aaa.java:15)
我的脚本是:
package readdata;
import java.net.*;
import java.io.*;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
public class aaa
{
public static void main(String[] args) throws Exception {
URL oracle = new URL(" the link ");
BufferedReader in = new BufferedReader(
new InputStreamReader(oracle.openStream()));
String inputLine;
StringBuilder a = new StringBuilder();
while ((inputLine = in.readLine()) != null)
a.append(inputLine);
in.close();
int i = 0;
Pattern p = Pattern.compile("Open");
Matcher m = p.matcher( a );
while (m.find()) {
i++;
System.out.println(i);
}
}
}
我是否可以绕过 cloudflare 来从 URL 读取数据?
Before
URL oracle = new URL(" the link ");
insert :
System.setProperty("http.agent", "Chrome");
这可能是因为 CloudFlare 阻止未知代理请求,因此此代码将用户代理设置为 CloudFlare 识别的 Chrome。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)