亚洲城地址

亚洲城地址官方网站下载安装

新闻发布日期:2018-4-25

从网址取得JSON时发生错误

我想从这个URL获取JSON,但它返回了以下错误:

1
2

<html><body><script type="text/javascript" src="/aes.js" ></script><script>function toNumbers(d){var e=[];d.replace(/(..)/g,function(d){e.push(parseInt(d,16))});return e}function toHex(){for(var d=[],d=1==arguments.length&&arguments[0].constructor==Array?arguments[0]:arguments,e="",f=0;f<d.length;f++)e+=(16>d[f]?"0":"")+d[f].toString(16);return e.toLowerCase()}var a=toNumbers("f655ba9d09a112d4968c63579db590b4"),b=toNumbers("98344c2eee86c3994890592585b49f80"),c=toNumbers("598f2de43d734f86c2ccb9e868e40332");document.cookie="__test="+toHex(slowAES.decrypt(c,2,a,b))+"; expires=Thu, 31-Dec-37 23:55:55 GMT; path=/"; location.href="http://android.aa8.ir/getAllDataManager.php?i=1";</script><noscript>This site requires Javascript to work, please enable Javascript in your browser or use a browser with Javascript support</noscript></body></html>

我使用这个类在Android中获取JSON:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44

public static String getData(String Address) {

URL url = null;

try {

url = new URL(Address);

HttpURLConnection connection = (HttpURLConnection) url.openConnection();

connection.setRequestMethod("GET");

connection.setRequestProperty("USER-AGENT", "Mozilla/5.0");

connection.setRequestProperty("ACCEPT-LANGUAGE", "en-US,en;0.5");

InputStream in = connection.getInputStream();

BufferedReader br = new BufferedReader(new InputStreamReader(in));

String line = "";

StringBuilder responseOutput = new StringBuilder();

while ((line = br.readLine()) != null) {

responseOutput.append(line);

}

br.close();

return responseOutput.toString();

} catch (Exception e) {

e.printStackTrace();

}

return "";

}

我认为这个错误是因为URL向我发送了cookies或Javascript。我必须如何从这个URL取得JSON?

该网址正在返回一个HTML。确保URL返回一个JSON,如果您确定URL返回一个JSON,那么您的错误可能在地址(错误的地址,甚至是键入错误)。

代码似乎很好。您还可以通过从示例JSON生成器请求JSON来检查代码