24 lines
755 B
Java
24 lines
755 B
Java
package com.yutou.nas.utils;
|
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
import java.net.URLEncoder;
|
|
|
|
public class RssXMLtoJson {
|
|
public static JSONObject toJSON(String xmlUrl){
|
|
String url = "https://api.rss2json.com/v1/api.json?rss_url=%s&api_key=wtfm5pebya13pnl8rtu51wfgfpte0mb9sap1foll&count=500";
|
|
try {
|
|
String ret = HttpTools.get(String.format(url, URLEncoder.encode(xmlUrl, "UTF-8")));
|
|
if(ret!=null){
|
|
return JSON.parseObject(ret, JSONObject.class);
|
|
}
|
|
} catch (UnsupportedEncodingException e) {
|
|
e.printStackTrace();
|
|
return null;
|
|
}
|
|
return null;
|
|
}
|
|
}
|