Skip to content

Instantly share code, notes, and snippets.

@arschmitz
Created November 1, 2010 17:22
Show Gist options
  • Save arschmitz/658533 to your computer and use it in GitHub Desktop.
Save arschmitz/658533 to your computer and use it in GitHub Desktop.
<?php
include ("simple_html_dom.php");
function import_special($brand, $result= "0"){
echo "<div class=\"special\">";
$page = "f_VehicleSearchResults?pageContext=VehicleSearch&search=new&campaign=0";
if($brand == "usedwestbrook") {
$brand = "westbrook";
$page = "f_VehicleSearchResults?pageContext=VehicleSearch&search=used&campaign=0";
}
if($brand == "usedbrunswick") {
$brand = "hyundai";
$page = "f_VehicleSearchResults?pageContext=VehicleSearch&search=used&campaign=0";
}
if ($brand == "kia") $brand = $brand.".net/";
else $brand = $brand.".com/";
$base = "http://www.billdodge";
$site = $base.$brand;
$url = $site.$page;
$data = file_get_contents($url);
$html = str_get_html($data);
$linkContainer = $html->find('div[class=results_media_img]', $result);
preg_match_all("/\VehicleDetails[[:print:]]+\>/", $linkContainer, $links);
$link = $links[0][0];
if($link != ""){
echo "<a href=\"".$site."$link";
preg_match_all("/img [[:print:]]+media[[:print:]]+ alt/", $data, $results);
$img = $results[0][$result];
echo "<$img>";
echo $html->find('h3',$result);
echo $html->find('li[class=featuredPrice]',$result);
$sale = $html->find('div[class=price_info_section]',$result)->find('li[class=salePrice]',0);
if($sale == "") echo "Finance Special!";
else echo $html->find('li[class=salePrice]',$result);
echo "</a>";
}
echo "</div>";
}
import_special('bmw');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment