-6
我的問題是,屏幕上有輸出。我無法從table class =「gallerybig」獲取文本和鏈接。請幫助。無法從網站獲取文本和鏈接使用jsoup的HTML解析
如果您不明白我的問題,可以通過[email protected]與我聯繫。
請參閱代碼中的olx鏈接。並檢查源代碼。
請檢查鏈接看圖像鏈接。
我的NetBeans乳寧這一點。
enter code here
Document doc;
try {
doc = (Document) Jsoup.connect("https://www.olx.in/sale/?view=galleryBig&page=4")
.userAgent("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20100101 Firefox/5.0")
.get();
String roottable = "tbody > tr";
Elements first = doc.select("body[class=offersview.standard.smallscreen.bodyIndent]");
Elements table = first.select("table[class=gallerybig]");
for(Element base : table){
for (Element t1:base.select(roottable)){
Elements td = t1.select("td[valign=top]");
Elements div = td.select("div[class=item.rel]");
Elements divinner = div.select("div[class=inner.brkword]");
Elements divclr = divinner.select("div[class=clr]");
Elements h4 = divclr.select("h4[class=normal.large.lheight24]");
Elements link = h4.select("a");
Elements select = link.select("a[href]");
Elements title = link.select("span");
String titles = title.text();
Elements pricetag = divclr.select("p[class=price.x-large]");
Elements strong = pricetag.select("strong[class=c000]");
String price = (String) strong.text();
Elements ptag = divclr.select("p[class=lheight18.color-1.margintop8]");
for (Iterator<Element> it = ptag.iterator(); it.hasNext();) {
Element ype = it.next();
String type = ype.text();
System.out.println(type.toString());
System.out.println("fg");
}
Elements span = ptag.select("span");
String place = span.text();
System.out.println(place);
System.out.println(titles);
System.out.println(price);
System.out.println(select);
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
輸出: - 運行: 生成成功(總時間:2秒)
有在屏幕上輸出。
而問題是什麼?請改善我們的問題以下https://stackoverflow.com/help/mcve –
如果你想要你可以聯繫我[email protected] – krunal