-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
run.php
103 lines (94 loc) · 3.53 KB
/
run.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
<?php
error_reporting(0);
/**
* Author : Wahyu Arif Purnomo
* Name : Shopee Scrape
* Version : 1.0
* Update : 04 Desember 2019
*
* If you are a reliable programmer or the best developer, please don't change anything.
* If you want to be appreciated by others, then don't change anything in this script.
* Please respect me for making this tool from the beginning.
*/
unlink('hasil/json/results.json');
require __DIR__ . '/vendor/autoload.php';
include "modules/function.php";
use \Curl\Curl;
$curl = new Curl();
$banner = "
@@@@@@@@@@@@((((((@@@@@@@@@@@
@@@@@@@@@@((#@@@@((%@@@@@@@@@
@@@@@@@@@((@@@@@@@@(&@@@@@@@@
@@@@@@@@#(@@@@@@@@@&(%@@@@@@@
@(((((((((((((//(((((((((((((
@(((((((((( ((((/ (((((((((( | AUTHOR : WAHYU ARIF PURNOMO
@(((((((((( ((((((((((((((((( | NAME : SHOPEE SCRAPE
@((((((((((/ /(((((((((((((( | VERSION: 1.0
@((((((((((((((/ .(((((((((( | UPDATE : 4 DESEMBER 2019
@(((((((((((((((((. ((((((((# | If you are a reliable programmer or the best developer, please don't change anything.
@#(((((((( (((((((. ((((((((@
@@(((((((((, (((((((((@
@@((((((((((((((((((((((((((@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
";
print $banner;
echo "\nMau cari apa? ";
$search = trim(fgets(STDIN));
echo "Berapa? ";
$totalSearch = trim(fgets(STDIN));
$getSearch = getSearch($curl, $search, $totalSearch);
if($getSearch->error == null) {
$no = 0;
for ($x = 0; $x < $totalSearch; $x++) {
$no++;
$itemID = $getSearch->items[$x]->itemid;
$shopID = $getSearch->items[$x]->shopid;
$getItem = getItem($curl, $itemID, $shopID);
$nameItem = $getItem->item->name;
$priceItem = $getItem->item->price;
//$diskonItem = $getItem->item->discount;
$statusItem = $getItem->item->item_status;
$lokasiToko = $getItem->item->shop_location;
$imageItem = 'https://cf.shopee.co.id/file/' . $getItem->item->image;
if($statusItem == "normal") {
$status = "Tersedia";
} else {
$status = "Tidak Tersedia";
}
echo $no . '. [' . $status . '] [' . $priceItem . '] [' . $nameItem . '] [' . $lokasiToko . '] [' . $imageItem . "] \n";
$export['data'][] = array(
'no' => $no,
'status' => $status,
'nama' => $nameItem,
'harga' => $priceItem,
'lokasi' => $lokasiToko,
'foto' => $imageItem,
'status' => $status
);
//echo json_encode($export) . "\n";
if (($id = fopen('hasil/json/results.json', 'wb'))) {
fwrite($id, json_encode($export));
fclose($id);
}
}
}
ob_start();
htmlConverter();
$htmlResults = ob_get_contents();
ob_end_clean();
file_put_contents("hasil/html/results.html", $htmlResults);
echo "\n\e[0;32mSuccessfully scrape data from Shopee.\e[0m\n\n";
echo "\e[0;31mFile saved :\n";
echo "JSON : hasil/json/results.json\n";
echo "HTML : hasil/html/results.html\e[0m";
/**
* Author : Wahyu Arif Purnomo
* Name : Shopee Scrape
* Version : 1.0
* Update : 04 Desember 2019
*
* If you are a reliable programmer or the best developer, please don't change anything.
* If you want to be appreciated by others, then don't change anything in this script.
* Please respect me for making this tool from the beginning.
*/
?>