OkHttpClient client=new OkHttpClient (.) newBuilder ()
.build();
Request the Request=new Request. Builder ()
Url (url)
Method (" GET ", null)
.build();
The Response the Response=client. NewCall (request). The execute ();
Return the response body (). The string ();
}
//lyrics
Public void getLyricFromGet () {
New Thread () {
@ Override
Public void the run () {
Super. The run ();
Try {
String Str=songList. Get (I). GetSong ();
String String []=Str. The split (" [] ");
//curl 'http://gecimi.com/api/lyric/sports/Beyond'
String url="http://geci.me/api/lyric/" + String [0]. The trim ();
System. The out. Println (url);
The String result=get (url);
The e (" TAG ", result);
The Message MSG=Message. Obtain ();
MSG. What=GET;
MSG. Obj=the result;
Handler. SendMessage (MSG);
} the catch (IOException e) {
e.printStackTrace();
}
}
}.start();
}
Access to the json array
2020-05-23 22:10:19.887 11397-11453/com.example.administrator.mdsd E/TAG: {"code":0,"count":7,"result":[{"aid":2418554,"artist_id":2,"lrc":"http://s.gecimi.com/lrc/284/28457/2845727.lrc","sid":2845727,"song":"囚鸟"},{"aid":1742006,"artist_id":13177,"lrc":"http://s.gecimi.com/lrc/190/19071/1907111.lrc","sid":1907111,"song":"囚鸟"},{"aid":1982846,"artist_id":13177,"lrc":"http://s.gecimi.com/lrc/223/22360/2236028.lrc","sid":2236028,"song":"囚鸟"},{"aid":1860329,"artist_id":15843,"lrc":"http://s.gecimi.com/lrc/206/20670/2067030.lrc","sid":2067030,"song":"囚鸟"},{"aid":2635202,"artist_id":15843,"lrc":"http://s.gecimi.com/lrc/315/31502/3150238.lrc","sid":3150238,"song":"囚鸟"},{"aid":2671022,"artist_id":42486,"lrc":"http://s.gecimi.com/lrc/319/31992/3199273.lrc","
How to extract the LRC England inside connection and then parsing lyrics for a great god
CodePudding user response:
Take no x
The Matcher Matcher=Pattern.com running (" (? <=\ "LRC England " : \ "). +? \ \. LRC England "). The matcher (jsonString);
While (the matcher. The find ()) {
System. The out. Println (matcher. Group ());
}
Or use fastjson object directly, also pretty convenient, also can get other information, their search fastjson tutorial
CodePudding user response:
Or use fastjson object directly, also pretty convenient, also can get other information, their search fastjson tutorialCodePudding user response: