2023年4月21日18:15:29

master
zhangmeng 2023-04-21 18:28:37 +08:00
parent 2bdd64d60e
commit 76dd77525d
1 changed files with 9 additions and 3 deletions

View File

@ -142,9 +142,15 @@ public class MusicDownloadController {
req.setParam(param); req.setParam(param);
query.setReq(req); query.setReq(req);
String q = JSON.toJSONString(query); String q = JSON.toJSONString(query);
String result2 = HttpRequest.post(api)
.header(Header.USER_AGENT, "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36")//头信息,多个头信息多次调用此方法即可 Map<String,String> headerMap=new HashMap<>();
.form(BeanUtil.beanToMap(query))//表单内容 headerMap.put("user-agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36 Edg/87.0.664.66");
headerMap.put("accept-encoding","application/json");
headerMap.put("cache-control","max-age=0");
String result2 = HttpRequest.post(api).headerMap(headerMap,false).header()
.form(q)//表单内容
.timeout(20000)//超时,毫秒 .timeout(20000)//超时,毫秒
.execute().body(); .execute().body();
QQMusic qqMusic = JSON.parseObject(result2, QQMusic.class); QQMusic qqMusic = JSON.parseObject(result2, QQMusic.class);