Kel*_*ing 5 html java android jsoup
我一直在尝试访问KissAnime,但是我一直收到此错误:
org.jsoup.HttpStatusException:提取URL时发生HTTP错误。状态= 503
当我尝试另一个URL例如。https://www.google.com/,效果很好。
这是我的asynctask代码:
@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;
}
Run Code Online (Sandbox Code Playgroud)
任何想法如何解决这个问题?
小智 2
要摆脱 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());
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
856 次 |
| 最近记录: |