paip.获取地理位置根据Ip
html转换txt
正则表达式截取mid
private static String addr(String ip) {
String urlContent = WebpageContent("http://www.123cha.com/ip/?q="+ip,"utf-8");
String txt=html2txt(urlContent);
String left="参考数据一:";
String add=com.attilax.text.strUtil.Mid(txt, left, "参考数据二:");
return add;
}
private static String html2txt(String urlContent) {
org.jsoup.nodes.Document doc = null;
//filex.write(path + ".htm", html);
doc = Jsoup.parse(urlContent);
return doc.text() ;
}
public static String getMidtrings(String s2,String left,String right) {
// String s2=" 周期 Statement?cycle 2013/11/15?-?2013/12/14 ";
// s2=doc.text();
String abcdef="abcdef";
String fd=left+"(.*?)"+right;
String s= strUtilO36.getMidtrings(s2, fd);
return s;
}
/**
*
* @param str
* @param find "qq(.*?)qq"
*/
public static String getMidtrings(String str,String find) {
// String str = "rrwerqq84461376qqasfdasdfrrwerqq84461377qqasfdasdaa654645aafrrwerqq84461378qqasfdaa654646aaasdfrrwerqq84461379qqasfdasdfrrwerqq84461376qqasfdasdf";
//"qq(.*?)qq"
Pattern p = Pattern.compile(find);
Matcher m = p.matcher(str);
ArrayList<String> strs = new ArrayList<String>();
while (m.find()) {
strs.add(m.group(1));
}
// for (String s : strs){
// System.out.println(s);
//// }
if(strs.size()==0)
return "";
return strs.get(0);
}