| px | top | add code | search | signup | login | help |
<?php
//E-bay auction harvester
//Rodney Helsens 2001
//
//This script will return a list of items for sale on ebay, you provide the search terms.
//clicking an item will open it in a new window, neat feature to add to your site.
//working example located at: http://www.fatbaq.com/ebay_harvester.php
//this is the search string, I have hard coded it. You might want to modify it to allow
//a user to enter this into a form.
$search="sheep\";
function getmicrotime() {
$mtime = microtime();
$mtime = explode(\" \",$mtime);
$mtime = $mtime[1] + $mtime[0];
return $mtime;
}
function buildfoot($begun = \"1\") {
$endtime = getmicrotime();
$pagetime = ceil($endtime - $begun);
$foot = \"$pagetime second(s)\";
return $foot;
}
$begintime = getmicrotime();
if(!($myFile=fopen(\"http://cq-search.ebay.com/search/search.dll?MfcISAPICommand=GetResult&pb=&ht=1&st=2&query=%28\" . $search . \"%29&SortProperty=MetaEndSort\",\"r\")))
{
echo \"<br><br>The E-bay website is not responding at the moment.\";
exit;
}
while(!feof($myFile))
{
$myLine.=fgets($myFile,255);
}
fclose($myFile);
// Extract everything between start and end.
$start=\"<!-- eBayCacheStart -->\";
$end=\"<!-- eBayCacheEnd -->\";
$start_position=strpos($myLine, $start);
$end_position=strpos($myLine, $end)+strlen($end);
$length=$end_position-$start_position;
$myLine=substr($myLine, $start_position, $length);
// Format the results and display it as HTML
$printing = str_replace(\"<font face=\\\"arial\\\" size=\\\"3\\\">\",\"<font face=arial size=1>\", $myLine);
$l = nl2br($printing);
$l = ereg_replace(\"<br>\", \"\", $l);
$l = ereg_replace(\"<a \", \"<a target=\\\"_blank\\\" \", $l);
$l = ereg_replace(\"<font size=3>\", \"<font size=1>\", $l);
$l = ereg_replace(\"\\r\", \"\", $l);
echo $l;
echo \"<br><br><font size=2><b>E-bay Auction scan completed in \" . buildfoot($begintime) . \"</b><br>\";
?>
Comments or questions?
PX is running PHP 5.2.11
Thanks to Miranda Productions for hosting and bandwidth.
Use of any code from PX is at your own risk.