-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patha101.php
76 lines (65 loc) · 2.2 KB
/
a101.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
<?php
require_once 'random-user-agent.php';
ini_set( 'max_execution_time', 59 * 60);
set_time_limit(59 * 60);
$siteURL='https://www.a101.com.tr/';
function siteConnect($site,$url,$kategorimi=false)
{
$tablo=[];
$ch = curl_init();
$hc = randomUserAgent();
curl_setopt($ch, CURLOPT_REFERER, 'http://www.google.com');
curl_setopt($ch, CURLOPT_URL, $site.$url);
curl_setopt($ch, CURLOPT_USERAGENT, $hc);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$siteFull= curl_exec ( $ch );
curl_close($ch);
if($kategorimi){
preg_match_all('@<li class="main(.*?)</li>@si',$siteFull,$data);
for($i = 0; $i<count($data[0]); $i++)
{
preg_match_all('/href="(.*?)"/s', $data[0][$i], $matches);
preg_match_all('/title="(.*?)"/s', $data[0][$i], $matches_title);
$link=$matches[1][0];
$title=$matches_title[1][0];
$tablo[]=array($link,$title);
}
return $tablo;
}else{
preg_match_all('@<div class="col-md-4 col-sm-6 col-xs-6 set-product-item">(.*?)<input@si',$siteFull,$data);
for($i = 0; $i<count($data[0]); $i++)
{
preg_match_all('/href="(.*?)"/s', $data[0][$i], $matches);
preg_match_all('/title="(.*?)"/s', $data[0][$i], $matches_title);
preg_match_all('@<span class="current">(.*?)</span>@si', $data[0][$i], $matches_fiyat);
preg_match_all('@src="https://ayb.akinoncdn.com/products/(.*?)"@si', $data[0][$i], $matches_resim);
$link=$matches[1][0];
$title=$matches_title[1][0];
$fiyat=$matches_fiyat[1][0];
$resim='https://ayb.akinoncdn.com/products/'.$matches_resim[1][0];
$hash_id=md5($link.$resim.$title);
$tablo[]=array('link'=>$link,'title'=>$title,'fiyat'=>$fiyat,'resim'=>$resim,'hash_id'=>$hash_id);
}
}
return $tablo;
}
$tablo=[];
$kategoriler=siteConnect($siteURL,'market/',true);
foreach($kategoriler as $kat)
{
$link=$kat[0]?$kat[0]:'market';
for($i = 1; $i<100000; $i++){
$tabloYeni=siteConnect($siteURL,$link.'/?page='.$i);
if(empty($tabloYeni)){
break;
}
$tablo=array_merge($tablo,$tabloYeni);
}
}
if(!empty($tablo)){
$Sonuc['ok']=$tablo;
}else{
$Sonuc['error']='Ürünler Bulunamadı.';
}
print_r(json_encode($Sonuc));
?>