在Java代码中解析html,获得其中的值
java获取string里面的html标签
<html>
<title>hello</title>
<head>
</head>
<body>
<form action="/FileUpload/Upload" method="post" enctype="multipart/form-data">
<input name="name"/>
<input type="file" name="head"/>
<input type="submit" value="upload"/>
</form>
</body>
</html>
Document doc = Jsoup.parse(html);//html为内容
Element e_title = doc.getElementsByTag("title").get(0);//根据标签名找title元素
String title = e_title.text();//获取标签的文字
获取form中的method值
Document doc = Jsoup.parse("s");
Element e_form = doc.getElementsByTag("form").get(0);
String method = e_form.attr("method");
Jsoup(一)Jsoup详解(官方)
java发送post请求以raw形式和 Params形式发送