public void readBankMandiri() throws Exception { HttpGet httpGet; HttpPost httpPost; HttpResponse resp; List<NameValuePair> formParams; UrlEncodedFormEntity entity; // open login page httpGet = new HttpGet("https://ib.bankmandiri.co.id/retail/Login.do?action=form&lang=in_ID"); resp = httpClient.execute(httpGet); EntityUtils.consume(resp.getEntity()); // login formParams = new ArrayList<NameValuePair>(); formParams.add(new BasicNameValuePair("action", "result")); formParams.add(new BasicNameValuePair("userID", "budi_handuk888")); formParams.add(new BasicNameValuePair("password", "123456")); formParams.add(new BasicNameValuePair("image.x", "0")); formParams.add(new BasicNameValuePair("image.y", "0")); entity = new UrlEncodedFormEntity(formParams, "UTF-8"); httpPost = new HttpPost("https://ib.bankmandiri.co.id/retail/Login.do"); httpPost.setEntity(entity); resp = httpClient.execute(httpPost); EntityUtils.consume(resp.getEntity()); // check if login success? String successUrl = "https://ib.bankmandiri.co.id/retail/Redirect.do?action=forward"; Header[] locationHeaders = resp.getHeaders("Location"); if (locationHeaders.length == 0 || locationHeaders[0].getValue().equals(successUrl) == false) { System.out.println("Login failed!"); return; } // open page to obtain account list httpGet = new HttpGet("https://ib.bankmandiri.co.id/retail/TrxHistoryInq.do?action=form"); resp = httpClient.execute(httpGet); // read content StringBuilder buffer = new StringBuilder(); InputStream instream = resp.getEntity().getContent(); BufferedReader reader = new BufferedReader(new InputStreamReader(instream)); String line; while ((line = reader.readLine()) != null) { buffer.append(line); } // find string between: <select name="fromAccountID"> and </select> String begin = "<select name=\"fromAccountID\">", end = "</select>"; int beginPos = buffer.indexOf(begin) + begin.length(), endPos = buffer.indexOf(end, beginPos); String accountStr = buffer.substring(beginPos, endPos); // account values is in each of <option value="{acc_id}">{acc_no}</option> ArrayList<String> accountList = new ArrayList<String>(); begin = "<option value=\""; end = "\""; beginPos = 0; endPos = 0; while (true) { if ( (beginPos = accountStr.indexOf(begin, endPos)) == -1) break; beginPos += begin.length(); if ( (endPos = accountStr.indexOf(end, beginPos)) == -1) break; // first account id will empty string "Silahkan Pilih" if (beginPos != endPos) { String accId = accountStr.substring(beginPos, endPos); accountList.add(accId); } } // get account statement formParams = new ArrayList<NameValuePair>(); formParams.add(new BasicNameValuePair("action", "result")); formParams.add(new BasicNameValuePair("fromAccountID", accountList.get(0))); // <--- baca account pertama saja formParams.add(new BasicNameValuePair("searchType", "R")); formParams.add(new BasicNameValuePair("fromDay", "3")); // <--- tanggal from & to, cukup jelas ya formParams.add(new BasicNameValuePair("fromMonth", "12")); formParams.add(new BasicNameValuePair("fromYear", "2010")); formParams.add(new BasicNameValuePair("toDay", "3")); formParams.add(new BasicNameValuePair("toMonth", "1")); formParams.add(new BasicNameValuePair("toYear", "2011")); formParams.add(new BasicNameValuePair("sortType", "Date")); formParams.add(new BasicNameValuePair("orderBy", "ASC")); entity = new UrlEncodedFormEntity(formParams, "UTF-8"); httpPost = new HttpPost("https://ib.bankmandiri.co.id/retail/TrxHistoryInq.do"); httpPost.setEntity(entity); resp = httpClient.execute(httpPost); // read content buffer = new StringBuilder(); instream = resp.getEntity().getContent(); reader = new BufferedReader(new InputStreamReader(instream)); while ((line = reader.readLine()) != null) { buffer.append(line + "\n"); } //find string between: <!-- Start of Item List --> and <!-- End of Item List --> begin = "<!-- Start of Item List -->"; end = "<!-- End of Item List -->"; beginPos = buffer.indexOf(begin) + begin.length(); endPos = buffer.indexOf(end, beginPos); String accountStmt = buffer.substring(beginPos, endPos); System.out.println(accountStmt); // logout httpGet = new HttpGet("https://ib.bankmandiri.co.id/retail/Logout.do?action=result"); resp = httpClient.execute(httpGet); EntityUtils.consume(resp.getEntity()); }
Kamis, 06 Januari 2011
Baca mutasi Bank Mandiri
Langganan:
Posting Komentar (Atom)
Ini Pakai bahasa apa gan... yang dari php ada gak gan? untuk mutasi mandiri nya.
BalasHapusjava
BalasHapusadakah script untuk phpnya bolehkan saya minta tolong dikirim ke email aam.amsori@gmail.com, terima kasih sebelumnya.
BalasHapusKomentar ini telah dihapus oleh pengarang.
BalasHapusKomentar ini telah dihapus oleh pengarang.
BalasHapusBERIKUT INI VERSI PHP:
BalasHapusset_time_limit(600);
$agent = "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:10.0.2) Gecko/20100101 Firefox/10.0.2";
$fcookie = dirname( __FILE__ ) . "/httpsCurl.cookie.txt";
function getMaxDay($year,$month) {
if( in_array($month,array(1,3,5,7,8,10,12)) ) return 31;
if( in_array($month,array(4,6,9,11)) ) return 30;
if($year%4 == 0) return 29; // kabisat sederhana //
return 28;
}
function httpsCurl($url,$urlref=false,$fields=false) {
global $fcookie, $agent;
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
if($urlref) {
curl_setopt($ch, CURLOPT_REFERER, $urlref);
}
if($fields) {
$fields_string = '';
foreach($fields as $key=>$value) {
$fields_string .= $key.'='.$value.'&';
}
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
curl_setopt($ch,CURLOPT_POST,count($fields));
} else {
curl_setopt($ch,CURLOPT_HTTPGET, TRUE);
}
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,TRUE);
curl_setopt($ch, CURLOPT_COOKIEJAR, $fcookie);
curl_setopt($ch, CURLOPT_COOKIEFILE, $fcookie);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
$html = curl_exec($ch);
return $html;
}
function baca_mutasi_bank_mandiri($userID, $password, $month,$year){
// LOGOUT //
$url0 = 'https://ib.bankmandiri.co.id/retail/Logout.do?action=result';
$result0 = httpsCurl($url0);
//file_put_contents('./result0.html',$result0);
//sleep(2);
// MASUK //
$url1 = 'https://ib.bankmandiri.co.id/retail/Login.do?action=form&lang=in_ID';
$result1 = httpsCurl($url1,$url0);
//file_put_contents('./result1.html',$result1);
//sleep(2);
// LOGIN //
$fields = array(
'action'=>urlencode("result")
, 'password'=>urlencode($password)
, 'userID'=>urlencode($userID)
, 'image.x'=>urlencode("0")
, 'image.y'=>urlencode("0")
);
$url2 = 'https://ib.bankmandiri.co.id/retail/Login.do';
$result2 = httpsCurl($url2,$url1,$fields);
//file_put_contents('./result2.html',$result2);
//sleep(2);
// BACA KODE CCOUNT //
$url3 = 'https://ib.bankmandiri.co.id/retail/TrxHistoryInq.do?action=form';
$result3 = httpsCurl($url3,$url2);
//file_put_contents('./result3.html',$result3);
//sleep(2);
$accID = strpos($result3,'name="fromAccountID"');
if( $accID && ($accID=strpos($result3,' value="',++$accID)) && ($accID=strpos($result3,' value="',++$accID)) ) {
$accID = substr($result3,$accID+8,15);
$accID = rtrim($accID, '"> ');
//echo $accID;
}
// BACA MUTASI SATU BULAN //
$max_day = getMaxDay($year,$month);
$fields = array(
'action'=>urlencode("result")
, 'fromAccountID'=>urlencode($accID)
, 'fromDay'=>urlencode("1")
, 'fromMonth'=>urlencode($month)
, 'fromYear'=>urlencode($year)
, 'orderBy'=>urlencode("ASC")
, 'searchType'=>urlencode("R")
, 'sortType'=>urlencode("Date")
, 'toDay'=>urlencode($max_day)
, 'toMonth'=>urlencode($month)
, 'toYear'=>urlencode($year)
);
$url4 = 'https://ib.bankmandiri.co.id/retail/TrxHistoryInq.do';
$result4 = httpsCurl($url4,$url3,$fields);
//file_put_contents('./result4.html',$result4);
//sleep(2);
// LOGOUT //
$resultx = httpsCurl($url0);
// file_put_contents('./resultx.html',$resultx);
return $result4;
}
$_userid = 'bamban1202';
$_passwd = '123456';
$_bulan = 10; // oktober
$_tahun = 2015;
$sret = baca_mutasi_bank_mandiri($_userid, $_passwd, $_bulan,$_tahun);
$iawal = strpos($sret,'');
$iakir = strpos($sret,'');
if($iawal && $iakir && $iawal<$iakir) {
echo substr($sret,$iawal,$iakir-$iawal);
} else {
echo "kosong";
}
gan chat saya lewat emal ya. ada penawaran cek mutasi ini.
BalasHapus