GankNew
GankNew copied to clipboard
大神求问gank的api中文如何处理
我只会简单的拼接,太高端的代码看不懂啊,我用这个:
String urlAPI = "http://gank.io/api/data/福利/12/" + startPage.toString();
System.out.println("妹子 url: " + urlAPI);
URL url = new URL(urlAPI);
connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
systemout: 妹子 url: http://gank.io/api/data/福利/12/3
浏览器没有问题啊,打印出来的url也是正确的啊,就是得不到数据:
{
05-12 12:23:59.599 25568-26062/com.ouman.luoliluoli I/System.out: "error": false,
05-12 12:23:59.599 25568-26062/com.ouman.luoliluoli I/System.out: "results": []
05-12 12:23:59.599 25568-26062/com.ouman.luoliluoli I/System.out: }
求大神指点迷津?
用HttpURLConnection的时候那个福利中文转码的问题,浏览器可以是因为浏览器最终转化为http://gank.io/api/data/%E7%A6%8F%E5%88%A9/12/3这种形式,所以你要在中文那里转码一下,代码是 URLEncoder.encode("福利", "UTF-8");就可以了
看了一下你的github,你的python好厉害哦
嘿嘿嘿,我研究人工智能方面的,最近写个坎美女的安卓app缓解一下寂寞的情绪,你懂的,以后可以交流交流安卓
可以呀,互相交流互相提高,我对人工智能也很感兴趣的,感觉太神奇了
我剪个一个安卓大神交流群,甚至有深度学习的大神,一起加进来交流一下 640302379
好,没问题