58,454
社区成员
发帖
与我相关
我的任务
分享
public String getData(String song) {
StringBuffer strBuf;
String songUrl ="http://songsearch.kugou.com/song_search_v2?callback=jQuery19103464" +
"2999175022426_1489023388639&keyword={"+song+"}&page=1&pagesize=30&" +
"userid=-1&clientver=&platform=WebFilter&tag=em&filter=2&iscorrection=1" +
"&privilege_filter=0&_=1489023388641";
strBuf = new StringBuffer();
try {
String line = null;
URL url = new URL(songUrl);
URLConnection conn = url.openConnection();
conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
// conn.setRequestMethod("GET");
//设置编码格式为UTF-8
conn.setRequestProperty("contentType", "UTF-8");
BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream(), "utf-8"));//转码。
while ((line = reader.readLine()) != null)
strBuf.append(line + " ");
reader.close();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return strBuf.toString();
// Handler hander = new Handler();
}