What I have so far is this:
package br.com.crawler;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.URL;
import javax.net.ssl.HttpsURLConnection;
public class Crawler {
private final String USER_AGENT = "Mozilla/5.0";
public static void main(String[] args) throws Exception {
Crawler http = new Crawler();
System.out.println("\nTesting 1 - Enviar request via POST");
http.sendPost();
}
// HTTP POST request
private void sendPost() throws Exception {
String url = "https://www.nfp.fazenda.sp.gov.br/login.aspx";
URL obj = new URL(url);
HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
//add reuqest header
con.setRequestMethod("POST");
con.setRequestProperty("User-Agent", USER_AGENT);
con.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
String urlParameters = "__EVENTVALIDATION=&"
+ "__EVENTARGUMENT=&"
+ "__VIEWSTATE=/wEPDwUKMTMwMTM2MTg2MA9kFgJmD2QWAgIBD2QWCgIDDxYCHgVjbGFzcwUYYmFycmFBY2Vzc2liaWxpZGFkZUxvZ2luFgQCAQ8WAh4HVmlzaWJsZWhkAgMPFgIfAWdkAgQPFgIfAWhkAgYPDxYCHgRUZXh0BRROb3RhIEZpc2NhbCBQYXVsaXN0YWRkAggPFgIfAWhkAgoPZBYCZg9kFgJmD2QWBAIJDw8WAh8BZ2RkAg8PZBYCAgUPZBYCAgEPZBYCAgEPDxYEHghUYWJJbmRleAENAB4JTWF4TGVuZ3RoAgRkZBgBBR5fX0NvbnRyb2xzUmVxdWlyZVBvc3RCYWNrS2V5X18WCAUtY3RsMDAkQ29udGV1ZG9QYWdpbmEkTG9naW4xJHJkQnRuQ29udHJpYnVpbnRlBTBjdGwwMCRDb250ZXVkb1BhZ2luYSRMb2dpbjEkcmRCdG5OYW9Db250cmlidWludGUFLWN0bDAwJENvbnRldWRvUGFnaW5hJExvZ2luMSRyZEJ0bkNvbnRhYmlsaXN0YQUrY3RsMDAkQ29udGV1ZG9QYWdpbmEkTG9naW4xJHJkQnRuRmF6ZW5kYXJpbwUnY3RsMDAkQ29udGV1ZG9QYWdpbmEkTG9naW4xJHJkQnRuUHJvY29uBTZjdGwwMCRDb250ZXVkb1BhZ2luYSRMb2dpbjEkcmRCdG5BZHZvZ2Fkb1JlcHJlc2VudGFudGUFL2N0bDAwJENvbnRldWRvUGFnaW5hJExvZ2luMSRpbWdCdG5BY2Vzc29DZXJ0Q1BGBTBjdGwwMCRDb250ZXVkb1BhZ2luYSRMb2dpbjEkaW1nQnRuQWNlc3NvQ2VydENOUEo=&"
+ "ctl00$ConteudoPagina$Login1$rblTipo=rdBtnNaoContribuinte&"
+ "ConteudoPagina$Login1$UserName="+user+"&"
+ "ctl00$ConteudoPagina$Login1$Password="+password;
// Send post request
con.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
wr.writeBytes(urlParameters);
wr.flush();
wr.close();
int responseCode = con.getResponseCode();
System.out.println("Enviando 'POST' request para a URL : " + url);
System.out.println("Parâmetros parameters : " + urlParameters);
System.out.println("Response Code: " + responseCode);
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
//print result
System.out.println(response.toString());
}
}
My question is that I do not know which parameters to pass.