title: R: getting data from website, method POST, dropdown menu options change
body: <p>I'm trying to use R to extract data from a website where I have to select information from 5 dropdown menus and then click on an export or consult button (<a href="http://200.20.53.7/dadosaguaweb/default.aspx" rel="nofollow noreferrer">http://200.20.53.7/dadosaguaweb/default.aspx</a>). I found this excellent thread: <a href="https://stackoverflow.com/questions/27381889/getting-data-in-r-as-dataframe-from-web-source">Getting data in R as dataframe from web source</a>, but it didn't answer my question because of some differences:</p>
  
  <p>1) The website's form's method is Post, not Get;</p>
  
  <p>I tried using the RHTMLForms package together with RCurl, in a way that would work for Post or Get. Namely:</p>
  
  <pre><code>baseURL &lt;- "http://200.20.53.7/dadosaguaweb/default.aspx"
  forms&lt;-getHTMLFormDescription(baseURL)
  form1&lt;-forms$form1
  dadosAgua&lt;-createFunction(form1)
  dadosDef&lt;-dadosAgua(75,"PS0421",1979,2015,6309)
  </code></pre>
  
  <p>2) The website is one of those where the list of options for the second dropdown menu changes according to what you selected for the first one and so on. Therefore, when I set the first input parameter to "75", it does not accept the second one as "PS0421" because that option is not available when the first parameter is at its default value.</p>
  
  <p>So, I tried a step-by-step approach, changing one parameter at a time, like this:</p>
  
  <pre><code>baseURL &lt;- "http://200.20.53.7/dadosaguaweb/default.aspx"
  forms1 &lt;- getHTMLFormDescription(baseURL)
  form1 &lt;- forms1$form1
  dadosAgua1 &lt;- createFunction(form1)
  dadosDef1 &lt;- dadosAgua1(75)
  
  forms2 &lt;- getHTMLFormDescription(dadosDef1)
  form2 &lt;- forms2$form1
  dadosAgua2 &lt;- createFunction(form2)
  dadosDef2 &lt;- dadosAgua2(75,"PS0421")
  </code></pre>
  
  <p>And I get the error message:
   Error in function (type, msg, asError = TRUE)  : Empty reply from server</p>
  
  <p>Now I'm completely stuck.</p>