Hello!
I need some help with screen scraping.
I want to take part of a website and show it in my website.
I found a wordpress plugin that would do the job and I have tried it, it works great. But my problem is that I dont use wordpress and want to use the script in a php file.
Simple and easy to use PlugIn to show a part of another website on your page. -The PHP tamer
This is were I found the plugin.
I think this is the code that I need to use in my php file. Problem is, I dont know how I should insert everything, because when its in wordpress you just use a shortcode.
So I need your help to show me were I should insert the URL, the starting tag, and the ending tag. Also showing me how the script should look in my php file so that it works.
$myurlstring = $url['url'];
$sample1=str_replace('>','>',str_replace('<','<',$url['sample1']));
$sample2=str_replace('>','>',str_replace('<','<',$url['sample2']));
$prefix=str_replace('>','>',str_replace('<','<',$url['prefix']));
$suffix=str_replace('>','>',str_replace('<','<',$url['suffix']));
$rfrom=str_replace('>','>',str_replace('<','<',$url['replace_from']));
$rto=str_replace('>','>',str_replace('<','<',$url['replace_to']));
$ckfile = tempnam ("/tmp", "CURLCOOKIE");
$ch = curl_init ($myurlstring);
curl_setopt ($ch, CURLOPT_COOKIEJAR, $ckfile);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec ($ch);
$ch = curl_init ($myurlstring);
//curl_setopt ($ch, CURLOPT_POST, 1);
//curl_setopt ($ch, CURLOPT_POSTFIELDS, "sType=Vehicle+VIN&vtype=A&vin=".$vinnumber);
curl_setopt ($ch, CURLOPT_COOKIEFILE, $ckfile);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
$all = curl_exec ($ch);
$dfpos=@strpos($all,$sample1);
$depos=@strpos($all,$sample2,$dfpos);
$div=$prefix.substr($all,$dfpos,$depos-$dfpos).$suffix;
$div=str_replace($rfrom,$rto,$div);
echo $div;
curl_close ($ch);
I will be thankful for any help.