Skip to content

Instantly share code, notes, and snippets.

@vrcca
Created February 6, 2015 21:18
Show Gist options
  • Save vrcca/2a5711dbe227c4572c7a to your computer and use it in GitHub Desktop.
Save vrcca/2a5711dbe227c4572c7a to your computer and use it in GitHub Desktop.
Como consultar o saldo disponível da Alelo.
package springangularjs;
import java.io.IOException;
import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
public class AleloConnector {
public static final String USER_AGENT = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.95 Safari/537.36";
public static final String URL_ALELO = "http://m.alelo.com.br/alelomobile/se.do";
public static void main(String[] args) throws IOException {
if (args.length == 0) {
System.out.println("INFORME O CARTÃO NOS PARÂMETROS!");
System.exit(-1);
}
String numeroCartao = args[0];
Connection connection = Jsoup.connect(URL_ALELO);
connection.header("Content-Type", "application/x-www-form-urlencoded");
connection.data("cartao", numeroCartao);
connection.userAgent(USER_AGENT);
Document document = connection.post();
Elements divValorDoSaldoDisponivel = document.select("div#saldoDisp .valor");
String saldo = divValorDoSaldoDisponivel.text();
System.out.printf("Seu saldo disponível é %s.", saldo);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment