嗨,我已經在這個問題上幾天了。作爲項目的一部分,我需要使用JSOUP將這個eBuyer Search網站的產品名稱和價格返回到我的應用程序中。從網站上颳去信息並列入清單?
我想知道3個問題,在一分鐘的代碼帶回產品名稱和該頁面上的所有價格作爲一個句子的所有H1頭。
- 有沒有一種方法可以解析Android中的信息,一次帶回一個項目並列出它,以及產品名稱而不是文本塊。
- 一旦正確的信息被列出,我將如何傾聽對該產品的特定點擊並將其存儲爲變量?
非常感謝你的幫助,上述
private class Title extends AsyncTask<Void, Void, Void> {
String h1,h3;
@Override
protected Void doInBackground(Void... params) {
try {
// Connect to the web site
Document element = Jsoup.connect("http://www.ebuyer.com/search?q=" + search).get();
h1 = element.body().getElementsByTag("h2").text();
h3 = element.body().getElementsByTag("h1").text();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void result) {
// Set title into TextView
TextView textView = (TextView) findViewById(R.id.textView3);
textView.setText(h3);
TextView textView2 = (TextView) findViewById(R.id.textView2);
textView2.setText(h1);
}
}
代碼是我使用JSOUP
圖片下面的方法是,當我搜索一個產品會發生什麼。所有的
謝謝你試試這個。 – Rueben