-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.php
110 lines (94 loc) · 3.46 KB
/
script.php
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
session_start();
/*
* greatrevenueproperty@gmail.com
* GR1qaz2wsx
*/
set_time_limit(0);
header('Content-Type: text/html; charset=utf-8');
include 'vendor/autoload.php';
use Goutte\Client;
$client = new Client();
$a = array();
$crawler = $client->request('GET', 'http://crm.bkkcitismart.com/');
$form = $crawler->selectButton('')->form();
//$crawler = $client->submit($form, array('data[User][user_name]' => "akekarirk_h", 'data[User][password]' => "waiwaiwai01"));
$crawler = $client->submit($form, array('data[User][user_name]' => $_GET['username'], 'data[User][password]' => $_GET['password']));
$crawler = $client->request('GET',"http://crm.bkkcitismart.com/Auth");
$crawler = $client->request('GET', 'http://crm.bkkcitismart.com/Properties');
$crawler = $client->request('GET', 'http://crm.bkkcitismart.com/properties/index/page:'.$_GET['page']);
$regexBookMark = '/(\'\/bookmark_group\/bookmarkgrp_popup\/runningnumber:)\w+(\/prop_id:)\d+(\/user_id:)\d+\'/';
$regexEdit = '/(\'\/properties\/edit\/prop_id:)\d+(\/ref_no:)\w+\'/';
$regexView = '/(\'\/properties\/propertyviewProject\/prop_id:)\d+\'/';
$dirFile = "edit";
if($_GET["download_type"] == "edit"){
$regex = $regexEdit;
$dirFile = "edit";
}
else if($_GET["download_type"] == "view"){
$regex = $regexView;
$dirFile = "view";
}
$subject = $crawler->html();
$matches = [];
preg_match_all($regex, $subject, $matches);
if(empty($matches[0])){
echo "Can't find data";
exit();
}
if($_GET['page'] == 1){
$files = glob($dirFile.'/*');
foreach($files as $file){
if(is_file($file))
@unlink($file);
}
}
foreach($matches[0] as $key=> $value){
$url = 'http://crm.bkkcitismart.com'.trim($value, "'");
$node = $client->request('GET', $url);
// $myfile = fopen($dirFile."/".$_GET['page']."_".$key.".html", "a") or die("Unable to open file!");
$txt = $node->html();
// fwrite($myfile, $txt);
// fclose($myfile);
file_put_contents($dirFile."/".$_GET['page']."_".$key.".html", $txt);
}
//$crawler->filter('.tblList')->each(function ($node) {
//
// print $node->text()."\n";
//
// $myfile = fopen("file/".$_GET['id'].".txt", "a") or die("Unable to open file!");
// $txt = $node->text()."--------------------------------------------------------------------------------------------------------------------------------- \n".PHP_EOL;
// fwrite($myfile, $txt);
// fclose($myfile);
//});
$_GET['page']++;
$url= "http://localhost/bkk/script.php?".http_build_query($_GET);
if ($_GET['page'] < $_GET["totalpage"] ) {
header("Refresh: 2; URL=$url");
echo "waiting sync page ".$_GET["page"]."/".$_GET["totalpage"];
} else {
echo "sync ok";
}
//header("Refresh: 15; URL=$url");
/*
for ($i=1;$i<5;$i++) {
$crawler = $client->request('GET', 'http://crm.bkkcitismart.com/properties/index/page:'.$i);
$crawler->filter('.tblList')->each(function ($node) {
print $node->text()."\n";
$myfile = fopen("file/data.txt", "a") or die("Unable to open file!");
$txt = $node->text()."--------------------------------------------------------------------------------------------------------------------------------- \n".PHP_EOL;
fwrite($myfile, $txt);
fclose($myfile);
});
}
*/
/*
$r = $crawler->filter('a[class="up-link"]')->each(function ($node) {
$a[] = $node->attr( 'rel' );
return $a;
});
foreach ($r as $value) {
echo $client->request('GET',"http://www.prakardproperty.com/properties/updatedate/".$value[0])->text();
}
*/
?>