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
<?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
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!
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/
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/
Re: [blind2uriz] Pull text from another website
By ross - June 24, 2009
Just another quick note. My idea in the previous post was based on this bit of code I found when doing some google searching:
Like I said though, that's probably as far as we can take this through support. Feel free to email in consulting (consulting@interactivetools.com). There might be some more options that way.
Thanks!
$cleaned = preg_replace('/<a href=\"(.*?)\">(.*?)<\/a>/', "\\2", $dirty)
Like I said though, that's probably as far as we can take this through support. Feel free to email in consulting (consulting@interactivetools.com). There might be some more options that way.
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/
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/