Jump to content

PHP Screen Scraping


qwerty456

Recommended Posts

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.