本来想用 import org.jsoup.Jsoup;
或者 import org.htmlparser.Parser;
可是 android 不支持 sun.com 原生java字节码执行 ,而是自成一家.
只能靠自己写了 ,例如: beanshell 抓取CSDN极客头条内容
TestHtmlParser.bsh
import java.net.*;
import java.io.*;
import org.json.*;
String utf8(String str){
return new String(str.getBytes("8859_1"),"UTF-8");
}
String getText(String txt,char c, tag){
int begin = txt.indexOf(c);
if (begin > -1){
begin += 1;
end = txt.indexOf(tag,begin);
if (begin
',"")));
}
}
}
}
ins.close();
} catch(e) {
print(e);
}
}
getPage("http://geek.csdn.net/new");
在android 4.2 上测试通过.