import java.io.IOException
import java.util.ArrayList
import java.util.HashMap
import java.util.List
import java.util.Map
import org.jsoup.Connection.Method
import org.jsoup.Connection.Response
import org.jsoup.Jsoup
public class JsoupTest {
public static void main(String[] args) throws IOException {
Map<String, String> map = new HashMap<>()
//map.put请根据自己的微博cookie得到
Response res = Jsoup.connect("http://weibo.com/u/别人的主页id")
.cookies(map).method(Method.GET).execute()
String s = res.body()
System.out.println(s)
String[] ss = s.split("<script>FM.view")
int i = 0
// pl_content_homeFeed
// pl.content.homeFeed.index
List<String> list = new ArrayList<>()
for (String x : ss) {
// System.out.println(i++ + "======================================")
// System.out.println(x.substring(0,
// x.length() > 200 ? 200 : x.length()))
// System.out.println("===========================================")
if (x.contains("\"html\":\"")) {
String value = getHtml(x)
list.add(value)
System.out.println(value)
}
}
// content=ss[8].split("\"html\":\"")[1].replaceAll("(\\\\t|\\\\n)",
// "").replaceAll("\\\\\"", "\"").replaceAll("\\\\/", "/")
// content=content.substring(0,
// content.length()<=13?content.length():content.length()-13)
// System.out.println(Native2AsciiUtils.ascii2Native(content))
}
public static String getHtml(String s) {
String content = s.split("\"html\":\"")[1]
.replaceAll("(\\\\t|\\\\n)", "").replaceAll("\\\\\"", "\"")
.replaceAll("\\\\/", "/")
content = content.substring(0,
content.length() <= 13 ? content.length()
: content.length() - 13)
return Native2AsciiUtils.ascii2Native(content)
}