scrap_kisel.php
2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
include('kisel.conf.php');
include('KiselScrap.php');
#$arrinqtelco = array('customerId' => '08122027896',
# 'product' => 'SI10',
# 'inquiry' => 'Inquiry',
# '_sourcePage' => 'fRCY-X8ZXOIcbgrf1BkkxBM7KTI7S6exLVsnXnUiXn8=',
# '__fp' => 'wIlI6mnh04Y='
# );
$kisel = new KiselScrap();
$redis = new Redis();
$redis->connect($redis_url);
$kisel->setSessionId($redis->get($redis_prefix.'01.sessionid'));
// get querystring
$kisel->setTrxParam($_REQUEST['reqid'], $_REQUEST['msisdn'], $_REQUEST['product']);
$arrinqtelco = array('customerId' => $kisel->msisdn,
'product' => $kisel->product,
'inquiry' => 'Inquiry',
'_sourcePage' => 'fRCY-X8ZXOIcbgrf1BkkxBM7KTI7S6exLVsnXnUiXn8=',
'__fp' => 'wIlI6mnh04Y='
);
$kisel->setRandomUserAgent();
$log = "";
// Format the date and time
$date = date("Y-m-d H:i:s");
$fd = fopen("scrapper_kisel.log", "a+");
$log = "[$date] Step-1 : get welcome page\n";
$log .= "--------------------------------\n";
$kisel->get_page($welcome_url);
if(!$kisel->session_status) {
print "masuk";
$log .= "Error Session Invalid. Please input session";
$err = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
$err .= "<trx_response>\n";
$err .= "<product>".$_REQUEST['product']."</product>\n";
$err .= "<msisdn>".$_REQUEST['msisdn']."</msisdn>\n";
$err .= "<info>SESSION INVALID !!!</info>\n";
$err .= "</trx_response>";
print $err;
}
sleep(1);
if($kisel->session_status) {
$log .= "[$date] Step-2 : get purchase telco page\n";
$log .= "--------------------------------\n";
$kisel->get_page($purchasetelco_url);
#$prevbal = array();
#$prevbal = $kisel->balance();
#print_r($prevbal);
sleep(1);
$log .= "[$date] Step-3 : send inquiry telco\n";
$log .= "--------------------------------\n";
$kisel->send_form($purchasetelco_url, $purchasetelco_url, $arrinqtelco);
$kisel->parseResponse("//table[@class='tblogin']/tbody/tr/td",0);
sleep(1);
$log .= "[$date] Step-4 : send purchase telco\n";
$log .= "--------------------------------\n";
$arrinqtelconext = array('goToPin' => 'next',
'_sourcePage' => $kisel->source_page,
'__fp' => $kisel->fp
);
$kisel->send_form($purchasetelco_url, $purchasetelco_url, $arrinqtelconext);
$kisel->parseResponse("//table[@class='tblogin']/tbody/tr/td",1);
$kisel->printResponseXML();
fwrite($fd, $log);
fclose($fd);
}
?>