Pull text from another website

3 posts by 2 authors in: Forums > CMS Builder
Last Post: June 24, 2009   (RSS)

By blind2uriz - June 23, 2009

I have been trying to figure this one out for awhile now. Does anyone know how to pull just text from another website w/o bringing the pictures over using php. I used this and got the whole page w/ pictures.

<?php $url="http://www.url-here.html";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec ($ch);
curl_close ($ch);
// you can do something with $data like explode(); or a preg match regex to get the exact information you need
echo $data; ?>

Any help is greatly appreciated. Thanks in advance.

John
John C. Morris
Interdimensional Designs
www.covdesigns.com

Re: [blind2uriz] Pull text from another website

By ross - June 24, 2009

Hi John

Thanks for posting!

This one will likely go a bit beyond what we can do in support but I think you'll want to try taking a look at the preg_replace() function:


http://ca2.php.net/preg_replace


That should let you remove everything between two characters so if you are stripping out images, set it up to remove everything from "<img" to ">". Of course, you'll then want to run another replace to get rid of all the <img> tags that first command would leave behind.

Now, it could end up being that there is a great function that will do this all at once. If anyone else out there had any ideas, let us know :).

Thanks!
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/