java Jsoup getElementsByClass返回空值
我正试图编写一个程序,从某个站点获取价格信息。我想获取第一个元素,但getElementsByClass返回空值
String site = new String("https://www.ebay.it/sch/i.html?_from=R40&_nkw=" + searches[n] +"vhs&_sacat=0&_sop=15");
Document document = Jsoup.connect(site).header("Accept-Encoding", "gzip, deflate").userAgent("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:23.0) Gecko/20100101 Firefox/23.0").timeout(600000).get();
elements = document.getElementsByClass("s-item__price").first();
prices[n] = elements.text();
这段代码在一个线程中,当我按下一个按钮时,该线程就会启动。这是按钮侦听器
findPrices.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
searches= new String[1000];
for (int t = 0; t < numeroEdit+1; t++) {
searches[t] = new String();
searches[t] = String.valueOf(editTexts[t].getText());
searches[t].replace(' ', '+');
}
Thread t1 = new Thread();
t1.start();
ll.removeAllViews();
ll.addView(addLine);
ll.addView(findPrices);
for(int l =0; l < numeroEdit; l++){
editTexts[l].setText(prices[l] + "l");
ll.addView(editTexts[l]);
editTexts[l].setText(prices[l]);
}
}
});
谢谢你的帮助
# 1 楼答案
点击示例中的链接不会显示有用的信息,因为搜索[n]没有解释。在这种形式下,一个有效的答案是不可能的。请改进你的例子