Java 使用Jsoup访问HTML,但收到错误代码503
我一直在尝试访问,但我一直收到以下错误: org.jsoup.HttpStatusException:获取URL时出现HTTP错误。状态=503 当我尝试另一个网址,例如,它的工作非常完美 这是我的异步任务代码:Java 使用Jsoup访问HTML,但收到错误代码503,java,android,html,jsoup,Java,Android,Html,Jsoup,我一直在尝试访问,但我一直收到以下错误: org.jsoup.HttpStatusException:获取URL时出现HTTP错误。状态=503 当我尝试另一个网址,例如,它的工作非常完美 这是我的异步任务代码: @Override protected Void doInBackground(Void... params) { try { // Connect to the web site Document docume
@Override
protected Void doInBackground(Void... params) {
try {
// Connect to the web site
Document document = Jsoup.connect("https://kissanime.to/AnimeList/")
.ignoreContentType(true)
.userAgent("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1")
.referrer("http://www.google.com")
.timeout(12000)
.followRedirects(true)
.get();
// Get the html document title
title = document.title();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
你知道如何解决这个问题吗?要摆脱503,下面的代码会很有用
public static void main(String[] args) throws IOException {
//This will get you out of Http 503
Document document = Jsoup.connect("https://kissanime.to/AnimeList/")
.userAgent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:49.0) Gecko/20100101 Firefox/49.0").ignoreHttpErrors(true).followRedirects(true).timeout(100000).ignoreContentType(true).get();
System.out.println(document.body());
}
我认为动机是反DoS工具(看看
cf\u清除
cookie)。