我想在我的网页浏览中只获得一个div(按类)。我对PHP或CSS一无所知,所以当我按类名解析时,我无法理解我应该怎么做。我想拍
<div class="container_wrap container_wrap_first main_color fullsize">
部分在这里,但它如此复杂,所以我真的不知道在doc.select上写什么(div。&#34; HERE&#34;)。谢谢你的建议。
Divs I Must Parse:
<div id="wrap_all">
<div class="mobil-logo">
<div id="main" data-scroll-offset="88">
<!--- header icerik sonu--->
<div class="container_wrap container_wrap_first main_color fullsize">
<div class="container">
这就是我在Main.java中尝试过的:
// webview settings here
loadJsoup();
public void loadJsoup(){
try {
doc = Jsoup.connect("http://isvecehliyet.se/mobil").timeout(10000).get();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Element ele = doc.select("div.entry-content-wrapper").first();
String html = ele.toString();
String mime = "text/html";
String encoding = "utf-8";
mWebview.loadData(html, mime, encoding);
}
答案 0 :(得分:1)
这对我有用:
String url = "http://isvecehliyet.se/mobil/";
Document doc = Jsoup.connect(url).get();
Elements e = doc.select("div.container").first().parents();
System.out.println(e);
部分输出:
<div class="container_wrap container_wrap_first main_color fullsize">
<div class="container">
<main class="template-page content av-content-full alpha units" role="main" itemprop="mainContentOfPage">
<article class="post-entry post-entry [...]