Bir kaç seçenek seçip araç fiyatınızı öğrenebilirsiniz. Araç fiyatları piyasada verilen ilanlara göre anlık olarak değişkenlik gösterebilir. Aklınıza geldikçe yeni piyasa fiyatını öğrenmeyi unutmayın.
Araç tipi, marka, model gibi seçenekleri seçerek en üst ve en alt verilen ilan fiyatlarını görebilir, model yılı girerek araç yaşına göre verilen en üst ve en alt fiyatları görebilirsiniz.
http://ulusanyazilim.com/works/araba
Kodları
<?php //arac.php içeriği
header("Content-Type: text/html; charset=UTF-8");
if(isset($_POST["vasita"])){//arac yukle
$site = "http://www.sahibinden.com".$_POST["vasita"];
$icerik = file_get_contents($site);
preg_match_all('@categoryList(.*?)ul>@si',$icerik,$cikti);
preg_match_all('@<a href="(.*?)">(.*?)</a>@si',$cikti[1][0],$c);
$y=count($c[1]);
echo '<select id="arac" class="form-control">';
echo '<option>Araç Seçiniz</option>';
for($x=0;$x<$y;$x++){
echo '<option value="'.$c[1][$x].'">'.$c[2][$x].'</option>';
}
echo '</select>';
echo '<script type="text/javascript">
$(document).ready(function() {
$("#sonuc").html("Seçmeye Devam Ediniz...");
$("#arac").bind("change",function(){
if($("#arac").val() != 0){
var arac=$("#arac option:selected").val();
var aractext=$("#arac option:selected").text();
$.ajax({
type: "POST",
url: "arac.php",
data: "arac="+arac,
dataType: "html",
beforeSend: function() {
$("#arac").after("<label id=\"arac\" class=\"bg-secondary text-white form-control\">"+aractext+"</label>");
$("#arac").remove();
},
success: function(data) {
$("#arac").after(data);
}
});
}
});
});
</script>';
}elseif(isset($_POST["arac"])){//model yukle
$site = "http://www.sahibinden.com".$_POST["arac"];
$icerik = file_get_contents($site);
preg_match_all('@categoryList(.*?)ul>@si',$icerik,$cikti);
if(isset($cikti[1][0])){
preg_match_all('@<a href="(.*?)">(.*?)</a>@si',$cikti[1][0],$c);
$y=count($c[1]);
echo '<select id="model" class="form-control">';
echo '<option>Araç Seçiniz</option>';
for($x=0;$x<$y;$x++){
echo '<option value="'.$c[1][$x].'">'.$c[2][$x].'</option>';
}
echo '</select>';
}else{
preg_match_all('@searchResultsCat(.*?)searchResultLeft-query@si',$icerik,$arama);
preg_match_all('@<a href="(.*?)">(.*?)</a>@si',$arama[1][0],$c);
$y=count($c[1]);
echo '<select id="model" class="form-control">';
echo '<option>Araç Seçiniz</option>';
for($x=3;$x<$y;$x++){
echo '<option value="'.$c[1][$x].'">'.$c[2][$x].'</option>';
}
echo '</select>';
}
echo '<script type="text/javascript">
$(document).ready(function() {
$("#model").bind("change",function(){
if($("#model").val() != 0){
var model=$("#model option:selected").val();
var modeltext=$("#model option:selected").text();
$.ajax({
type: "POST",
url: "arac.php",
data: "model="+model,
dataType: "html",
beforeSend: function() {
$("#model").after("<label id=\"model\" class=\"bg-secondary text-white form-control\">"+modeltext+"</label>");
$("#model").remove();
},
success: function(data) {
$("#model").after(data);
}
});
}
});
});
</script>';
}elseif(isset($_POST["model"])){//seri yukle
$site = "http://www.sahibinden.com".$_POST["model"];
$icerik = file_get_contents($site);
preg_match_all('@categoryList(.*?)ul>@si',$icerik,$cikti);
if(isset($cikti[1][0])){
preg_match_all('@<a href="(.*?)">(.*?)</a>@si',$cikti[1][0],$c);
$y=count($c[1]);
echo '<select id="seri" class="form-control">';
echo '<option>Araç Seçiniz</option>';
for($x=0;$x<$y;$x++){
echo '<option value="'.$c[1][$x].'">'.$c[2][$x].'</option>';
}
echo '</select>';
}else{
preg_match_all('@searchResultsCat(.*?)searchResultLeft-query@si',$icerik,$arama);
preg_match_all('@<a href="(.*?)">(.*?)</a>@si',$arama[1][0],$c);
$y=count($c[1]);
echo '<select id="seri" class="form-control">';
echo '<option>Araç Seçiniz</option>';
for($x=4;$x<$y;$x++){
echo '<option value="'.$c[1][$x].'">'.$c[2][$x].'</option>';
}
echo '</select>';
}
echo '<script type="text/javascript">
$(document).ready(function() {
$("#seri").bind("change",function(){
if($("#seri").val() != 0){
var seri=$("#seri option:selected").val();
var seritext=$("#seri option:selected").text();
$.ajax({
type: "POST",
url: "arac.php",
data: "seri="+seri,
dataType: "html",
beforeSend: function() {
$("#seri").after("<label id=\"seri\" class=\"bg-secondary text-white form-control\">"+seritext+"</label>");
$("#seri").remove();
},
success: function(data) {
$("#seri").after(data);
}
});
}
});
});
</script>';
}elseif(isset($_POST["seri"])){//tur yukle
$site = "http://www.sahibinden.com".$_POST["seri"];
$icerik = file_get_contents($site);
preg_match_all('@categoryList(.*?)ul>@si',$icerik,$cikti);
if(isset($cikti[1][0])){
preg_match_all('@<a href="(.*?)">(.*?)</a>@si',$cikti[1][0],$c);
$y=count($c[1]);
echo '<select id="tur" class="form-control">';
echo '<option>Araç Seçiniz</option>';
for($x=0;$x<$y;$x++){
echo '<option value="'.$c[1][$x].'">'.$c[2][$x].'</option>';
}
echo '</select>';
}else{
preg_match_all('@searchResultsCat(.*?)searchResultLeft-query@si',$icerik,$arama);
preg_match_all('@<a href="(.*?)">(.*?)</a>@si',$arama[1][0],$c);
$y=count($c[1]);
if($y != 5){
echo '<select id="tur" class="form-control">';
echo '<option>Araç Seçiniz</option>';
for($x=5;$x<$y;$x++){
echo '<option value="'.$c[1][$x].'">'.$c[2][$x].'</option>';
}
echo '</select>';
}else{
yil($_POST["seri"]);
}
}
echo '<script type="text/javascript">
$(document).ready(function() {
$("#tur").bind("change",function(){
if($("#tur").val() != 0){
var tur=$("#tur option:selected").val();
var turtext=$("#tur option:selected").text();
$.ajax({
type: "POST",
url: "arac.php",
data: "tur="+tur,
dataType: "html",
beforeSend: function() {
$("#tur").after("<label id=\"tur\" class=\"bg-secondary text-white form-control\">"+turtext+"</label>");
$("#tur").remove();
},
success: function(data) {
$("#tur").after(data);
}
});
}
});
});
</script>';
}elseif(isset($_POST["tur"])){//yil yukle
yil($_POST["tur"]);
}elseif(isset($_POST["yil"])){//fiyat yukle
tablo($_POST["link"],$_POST["yil"]);
}elseif(isset($_POST["cek"])){//fiyat yukle
tablo($_POST["cek"]);
}else{
$site = "http://www.sahibinden.com/kategori/vasita";
$icerik = file_get_contents($site);
//echo $icerik;
preg_match_all('@categoryList(.*?)ul>@si',$icerik,$cikti);
preg_match_all('@<a href="(.*?)">(.*?)</a>@si',$cikti[1][0],$c);
$y=count($c[1]);
for($x=0;$x<$y;$x++){
echo '<option value="'.$c[1][$x].'">'.$c[2][$x].'</option>';
}
}
function yil($link){
echo '<input type="number" min="1900" max="2100" id="yil" class="form-control" placeholder="Model Yılı">';
echo '<script type="text/javascript">
$(document).ready(function() {
$.ajax({
type: "POST",
url: "arac.php",
data: "cek='.$link.'",
dataType: "html",
beforeSend: function() {
$("#sonuc").html("Yükleniyor...");
},
success: function(data) {
$("#sonuc").html(data);
}
});
$("#yil").on("input", function() {
var yil=$("#yil").val();
if(yil > 1900 && yil < 2100){
$.ajax({
type: "POST",
url: "arac.php",
data: "yil="+yil+"&link='.$link.'",
dataType: "html",
beforeSend: function() {
$("#sonuc").html("Yükleniyor...");
},
success: function(data) {
$("#sonuc").html(data);
}
});
}
});
});
</script>';
}
function tablo($link,$yil=null){
echo '<script type="text/javascript">
$(document).ready(function() {
$("#img").remove();
});
</script>';
$data=null;
if($yil != null){
$data["a5_min"]=$yil;
$data["a5_max"]=$yil;
}
$data["sorting"]="price_asc";
$site = "http://www.sahibinden.com".$link."?".http_build_query($data);
$icerik = file_get_contents($site);
preg_match_all('@searchResultsRowClass(.*?)tbody>@si',$icerik,$arama);
if(isset($arama[1][0])){
preg_match('@<tr(.*?)tr>@si',$arama[1][0],$tr);
preg_match_all('@<td class="searchResultsAttributeValue">(.*?)</td>@si',$tr[1],$td);
preg_match('@searchResultsPriceValue">(.*?)</td>@si',$tr[1],$tl);
$data["sorting"]="price_desc";
$site = "http://www.sahibinden.com".$link."?".http_build_query($data);
$icerik = file_get_contents($site);
preg_match_all('@searchResultsRowClass(.*?)tbody>@si',$icerik,$arama);
preg_match('@<tr(.*?)tr>@si',$arama[1][0],$tr);
preg_match_all('@<td class="searchResultsAttributeValue">(.*?)</td>@si',$tr[1],$td2);
preg_match('@searchResultsPriceValue">(.*?)</td>@si',$tr[1],$tl2);
echo '<table class="table">
<tbody>
<tr>
<td><b>Renk</b> : '.$td[1][2].'<br>
<b>KM</b> : '.$td[1][1].'<br>
<b>Yıl</b> : '.$td[1][0].'
</td>
<td><b>En Ölü Fiyat</b><br>'.strip_tags($tl[1]).'</td>
</tr>
<tr>
<td><b>Renk</b> : '.$td2[1][2].'<br>
<b>KM</b> : '.$td2[1][1].'<br>
<b>Yıl</b> : '.$td2[1][0].'
<td><b>En Temiz Fiyat</b><br>'.strip_tags($tl2[1]).'</td>
</tr>
</tbody>
</table>';
}else{
echo '<table class="table">
<thead class="thead-light">
<tr>
<th scope="col">Sonuc Bulunamadi</th>
</tr>
</thead>
</table>';
}
}