QQ音乐 查询歌曲 获取试听地址
本帖最后由 萋小磊 于 2017-12-23 23:22 编辑用到的jar包
jsoup-1.11.2.jar
json-20140107.jar
接口是QQ音乐的 解析是百度搜索到的
https://c.y.qq.com/splcloud/fcgi ... 0&format=jsonp&key=歌曲名
仅供参考
Scanner in = new Scanner(System.in);
String name = in.next();
List<String> midList = new ArrayList<String>();
try {
Document doc = Jsoup
.connect("https://c.y.qq.com/splcloud/fcgi-bin/smartbox_new.fcg?is_xml=0&format=jsonp&key="+name)
.get();
JSONObject jsonObject = new JSONObject(doc.body().html());
if(jsonObject.getInt("code") != -4){
JSONArray jsonArray =jsonObject.getJSONObject("data").getJSONObject("song").getJSONArray("itemlist");
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject jsob = (JSONObject) jsonArray.get(i);
System.out.println(jsob.getString("name").toString());
midList.add(jsob.getString("mid").toString());
}
}else{
System.out.println("没有找到此歌曲检查歌曲名或者歌手是否正确");
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(midList != null){
for (String mid : midList) {
try {
String json = Jsoup.connect("https://www.sinsyth.com/lxapi/ssk/qqmusic.php")
.data("surl","https://y.qq.com/n/yqq/song/"+ mid +".html")
.data("strkey","qq_Music17_jiexi")
.userAgent(" Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:57.0) Gecko/20100101 Firefox/57.0")
.timeout(5000)
.post()
.body()
.text();
JSONObject json1 = new JSONObject(json);
System.out.println(json1.getJSONObject("Rendata").getString("songURL"));
} catch (IOException e) {
e.printStackTrace();
}
}
}
有意思,接口是php的,这个是java写的。。。6得飞起 下来看看. 下来看看.
页:
[1]