title: Jsoup multiple connections - using already parsed element for URL
body: <p>Here's my PocetnaFragment.java: </p>
  
  <pre><code>package gimbi.edu.ba;
  
  import java.util.ArrayList;
  import java.util.HashMap;
  
  import org.jsoup.Jsoup;
  import org.jsoup.nodes.Document;
  import org.jsoup.nodes.Element;
  import org.jsoup.select.Elements;
  
  import android.app.Fragment;
  import android.content.Context;
  import android.net.ConnectivityManager;
  import android.net.NetworkInfo;
  import android.os.AsyncTask;
  import android.os.Bundle;
  import android.app.ProgressDialog;
  import android.os.Handler;
  import android.support.v4.widget.SwipeRefreshLayout;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.ListView;
  
  import com.nhaarman.listviewanimations.appearance.AnimationAdapter;
  import com.nhaarman.listviewanimations.appearance.simple.SwingBottomInAnimationAdapter;
  import com.nispok.snackbar.Snackbar;
  import com.software.shell.fab.ActionButton;
  
  public class PocetnaFragment extends Fragment {
  
      ListView listview;
      ListViewAdapter adapter;
      ProgressDialog mProgressDialog;
      ArrayList&lt;HashMap&lt;String, String&gt;&gt; arraylist;
      static String SEKCIJA = "sekcija";
      static String NASLOV = "naslov";
      static String LINK = "link";
      static String SLIKA = "slika";
      // URL Address
      String url = "http://gimnazijabihac.edu.ba";
  
      private SwipeRefreshLayout swipeView;
  
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
  
          // Inflate the layout for this fragment
  
          View view = inflater.inflate(R.layout.fragment_pocetna, container, false);
  
          listview = (ListView) view.findViewById(R.id.pocetna_listview);
          ActionButton actionButton = (ActionButton) view.findViewById(R.id.action_button);
  
          actionButton.setOnClickListener(new View.OnClickListener() {
              public void onClick(View v) {
                  if(!isNetworkAvailable(getActivity())) {
                      Snackbar.with(getActivity()) // context
                              .text("Neuspjela konekcija.") // text to display
                              .duration(Snackbar.SnackbarDuration.LENGTH_LONG) // make it shorter
                              .show(getActivity()); // activity where it is displayed
                  } else {
                  new JsoupListView().execute();
                  }
              }
          });
  
          swipeView = (SwipeRefreshLayout) view.findViewById(R.id.pocetna_swipe);
          swipeView.setColorScheme(android.R.color.holo_blue_dark, android.R.color.holo_blue_light, android.R.color.holo_green_light, android.R.color.holo_green_light);
          swipeView.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
              @Override
              public void onRefresh() {
                  swipeView.setRefreshing(true);
                  (new Handler()).postDelayed(new Runnable() {
                      @Override
                      public void run() {
                          new JsoupListView().execute();
                          swipeView.setRefreshing(false);
                      }
                  }, 500);
              }
          });
  
          if(!isNetworkAvailable(getActivity())) {
              Snackbar.with(getActivity()) // context
                      .text("Neuspjela konekcija.") // text to display
                      .duration(Snackbar.SnackbarDuration.LENGTH_LONG) // make it shorter
                      .show(getActivity()); // activity where it is displayed
          }
  
              new JsoupListView().execute();
  
          return view;
      }
  
      public boolean isNetworkAvailable(Context context) {
  
          ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
          NetworkInfo netinfo = cm.getActiveNetworkInfo();
  
          if (netinfo != null &amp;&amp; netinfo.isConnectedOrConnecting()) {
              android.net.NetworkInfo wifi = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
              android.net.NetworkInfo mobile = cm.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
  
              if((mobile != null &amp;&amp; mobile.isConnectedOrConnecting()) || (wifi != null &amp;&amp; wifi.isConnectedOrConnecting())) return true;
              else return false;
          } else
              return false;
      }
  
      // Title AsyncTask
      private class JsoupListView extends AsyncTask&lt;Void, Void, Void&gt; {
  
          @Override
          protected void onPreExecute() {
              super.onPreExecute();
              mProgressDialog = new ProgressDialog(getActivity(), ProgressDialog.THEME_HOLO_LIGHT);
              mProgressDialog.setMessage("Učitavanje..");
              mProgressDialog.setIndeterminate(false);
              mProgressDialog.show();
          }
  
          @Override
          protected Void doInBackground(Void... params) {
              arraylist = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
              Elements aEles = null;
              Elements divRightPostEles = null;
              String rightNaslov = null;
              Document doc = null;
  
              try {
                  doc = Jsoup.connect(url).get();
  
                  /** Get A tag that is under DIV with classname right_naslov **/
                  aEles = doc.select("div.right_naslov &gt; a");
                  if (aEles != null &amp;&amp; aEles.size() &gt; 0) {
                      if (aEles.size() == 2)
                          rightNaslov = aEles.get(1).ownText();
                      else
                          rightNaslov = aEles.first().ownText();
                  }
  
                  /**
                   * Since you say there are multiple DIV with right_post as
                   * classname, we will get all those right post elements and loop
                   * them one by one to retrieve its inner elements
                   **/
                  divRightPostEles = doc.select("div.right_post");
  
                  for (Element rightPostDiv : divRightPostEles) {
                      /** Each loop of this represents a right_post DIV element **/
  
                      HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
  
                      /**
                       * Get Font tag with [classname=nadnaslov] under
                       * span[classname=right_post_nadnaslov] under
                       * div[lassname=right_post]
                       **/
                      /** Try to get Font[classname=naslov] with the following method **/
                      Elements fontNadnaslov = rightPostDiv
                              .select("span.right_post_nadnaslov &gt; font.nadnaslov");
  
                      /**
                       * Get A tag that is under div[classname=right_post_tekst] under
                       * div[classname=right_post]
                       **/
                      Element aRightPostTekst = rightPostDiv.select(
                              "div.right_post_tekst &gt; a[href]").first();
  
                      // Retrive Jsoup Elements
                      if (fontNadnaslov != null &amp;&amp; fontNadnaslov.size() &gt; 0) {
                          map.put("naslov", fontNadnaslov.first().ownText());
  
                          if (aRightPostTekst != null) {
                              map.put("link", aRightPostTekst.attr("href"));
  
                              Element img = aRightPostTekst.select("img[src]").first();
  
                              if (img != null)
                                  map.put("slika", "http://gimnazijabihac.edu.ba/" + img.attr("src"));
                          }
  
                          if (rightNaslov != null)
                              map.put("sekcija", rightNaslov);
                          // Set all extracted Jsoup Elements into the array
                          arraylist.add(map);
                      }
                  }
              } catch (Exception e) {
                  e.printStackTrace();
              }
              return null;
          }
  
          @Override
          protected void onPostExecute(Void result) {
              // Pass the results into ListViewAdapter.java
              adapter = new ListViewAdapter(getActivity(), arraylist);
              AnimationAdapter animationAdapter = new SwingBottomInAnimationAdapter(adapter);
              animationAdapter.setAbsListView(listview);
              // Set the adapter to the ListView
              listview.setAdapter(animationAdapter);
              // Close the progressdialog
              mProgressDialog.dismiss();
          }
      }
  
  }
  </code></pre>
  
  <p>As usually, I'm parsing some data with jsoup within an AsyncTask. Now, I need to parse another url that should contain an element or w/e, e.g. <code>aRightPostTekst.attr("href")</code>.</p>
  
  <p>Could I do it inside the same asynctask or should I make a new one?</p>
  
  <p>Basically I need my url to be:</p>
  
  <p><code>"http://url.com/" + aRightPostTekst.attr("href")</code></p>
  
  <p>And then I should parse some other elements and put in the arraylist and then later, use it.</p>
  
  <p>Is it possible, like multiple connections and using an element for an url?</p>
  
  <p>I'm parsing from the following website: <code>http://gimnazijabihac.edu.ba/</code>, and I'm parsing the href tag inside the async task like lets say: <code>/e-novine/n/?id=340</code>, then the full url is: <code>http://gimnazijabihac.edu.ba/e-novine/n/?id=340</code></p>
  
  <p>And I should parse html from that specific website.</p>
  
  <p>Thanks in advance.</p>