Reputation: 105
How to use jsoup for making a loop in URL to request data parameters?
The loop I made take long time.
for example
static String[] cValues = {"AED", "AFN", "ALL", "AMD", "ANG","AOA","ARS","AUD","AZN","BBD","BDT","BGN","BHD","BIF"};
for(int i=0;i<cValues.length;i++){
for(int y=0;y<cValues.length;y++) {
doc = Jsoup.connect("http://www.zzz.com/finance/converter?a=1&from="+cValues[i]+"&to="+cValues[y]+"").get();
Element m = doc.select("div#zzz").first();
System.out.println(cValues[i] + "-" + cValues[y] + m.child(0).text());
}}
Upvotes: 0
Views: 212
Reputation: 1385
You use a sequential programming approach, as a result you code execution stuck for each request and resume when the response is received. Use AsyncTask for each Jsoup request.
See this example, this example use AsyncTask with the Jsoup.
Upvotes: 1