package test;
import java.io.File;
import java.io.IOException;
import org.json.JSONException;
import org.json.JSONObject;
import org.jsoup.Jsoup;
import tool.MyFileWriter;
public class JsoupOp {
public static void main(String[] args) {
// TODO Auto-generated method stub
String url = "http://uvs.youdao.com/search?site=photogalaxy.163.com&sort=time&channelid=&q=%B7%C9%BB%FA&length=50&start=0";
try {
String doc = getDoc(url);
getHits(doc);
} catch (IOException | JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void getHits(String doc) throws JSONException{
String json = doc.substring(doc.indexOf("{"), doc.lastIndexOf("}")+1);
json = json.replaceAll(" ", "");
JSONObject jsonObject = new JSONObject(json);
String hits = jsonObject.getString("hits");
hits = hits.substring(hits.indexOf("[")+1, hits.lastIndexOf("]"));
System.out.println(hits);
//MyFileWriter.writerStringTofile(new File("d:/test1.txt"), q, false);
/*
String name = jsonObject.getString("name");
int age = jsonObject.getInt("age");
boolean male = jsonObject.getBoolean("male");
JSONObject addressJSON = jsonObject.getJSONObject("address");
String street = addressJSON.getString("street");
String city = addressJSON.getString("city");
String country = addressJSON.getString("country");
*/
}
public static String getDoc(String url) throws IOException{
String body = null;
body = Jsoup.connect(url).ignoreContentType(true).execute().body();
return body;
}
}
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
机房租用,北京机房租用,IDC机房托管, http://www.fwqtg.net
相关推荐: 如何在金融企业推进故障演练?中国人寿分阶段实践总结
一分钟精华速览 越来越多企业正在通过故障注入和演练的方式提升系统可靠性,这其中金融行业的应用较为特殊。一方面其可靠性要求比非涉账类系统更高;另一方面金融行业有更加严格的监管要求,如客户、账目等信息都有严格约束。加之金融系统较其他行业系统更加庞大、繁杂,所以金融…