-
-
Save albertobraschi/f52c59cb89f355f348f7 to your computer and use it in GitHub Desktop.
Como consultar o saldo disponível da Alelo.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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