title: Using Jsoup to submit a form that has select inputs in Android
body: <p>Hi guys I am new to Android App development. I am currently trying to develop an app that shows the route of two places and I found out the data from <a href="https://mrt.sg/fare" rel="nofollow noreferrer">https://mrt.sg/fare</a> is quite useful for me. The form of the page contains two select type inputs and a submit button. I tried to use Jsoup to fill and submit the form and get the result, but I couldn't. This is my code.
  Can anyone help me? Thanks!</p>
  <pre><code>import androidx.appcompat.app.AppCompatActivity;
  
  import android.os.AsyncTask;
  import android.os.Bundle;
  import android.util.Log;
  import android.widget.TextView;
  
  import org.jsoup.Connection;
  import org.jsoup.Jsoup;
  import org.jsoup.nodes.Document;
  import org.jsoup.nodes.Element;
  import org.jsoup.select.Elements;
  
  import java.io.IOException;
  
  public class MainActivity extends AppCompatActivity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      Content content = new Content();
      content.execute();
  }
  
  private class Content extends AsyncTask&lt;Void, Void, Void&gt; {
      @Override
      protected void onPreExecute() {
          super.onPreExecute();
      }
  
      @Override
      protected void onPostExecute(Void aVoid) {
          super.onPostExecute(aVoid);
      }
  
      @Override
      protected void onCancelled(Void aVoid) {
          super.onCancelled(aVoid);
      }
  
      @Override
      protected Void doInBackground(Void... voids) {
          try{
              /*
              Document doc = Jsoup.connect(&quot;https://mrt.sg/fare&quot;).get();
              Elements options = doc.select(&quot;select#stn_a&gt;option&quot;);
              for (Element option : options) {
                  System.out.println(&quot;label: &quot; + option.text() + &quot;, value: &quot; + option.attr(&quot;value&quot;));
              }
              Log.d(&quot;&quot;,&quot;doc: &quot; +doc);
               */
  
              Connection.Response res = Jsoup.connect(&quot;https://mrt.sg/fare&quot;)
                      .data(&quot;stn_a&quot;, &quot;hj&quot;).data(&quot;stn_b&quot;, &quot;zl&quot;).method(Connection.Method.POST).execute();
              Document doc = res.parse();
              String data = doc.select(&quot;div#results_tripcalc&quot;).text();
              Log.d(&quot;Result&quot;,&quot;result: &quot; +data);
          } catch (IOException e) {
              e.printStackTrace();
          }
          return null;
      }
  }
  }
  </code></pre>