吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 4431|回复: 3
收起左侧

[Java 转载] QQ音乐 查询歌曲 获取试听地址

[复制链接]
萋小磊 发表于 2017-12-23 23:15
本帖最后由 萋小磊 于 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=歌曲名
仅供参考

[Java] 纯文本查看 复制代码
                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();
                                }
                        }
                }
        

免费评分

参与人数 2吾爱币 +9 热心值 +2 收起 理由
Godfather.Cr + 8 + 1 欢迎分析讨论交流,吾爱破解论坛有你更精彩!
TCY + 1 + 1 感谢发布原创作品,吾爱破解论坛因你更精彩!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

TCY 发表于 2017-12-23 23:45
有意思,接口是php的,这个是java写的。。。6得飞起
FJ19950531 发表于 2017-12-24 09:23
zsw56740 发表于 2018-1-10 15:17
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-5-15 18:17

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表