MorphixNW Posted May 7, 2014 Share Posted May 7, 2014 Hi There, I am using this code to get data from a remote URL, whilst the code does work it is returning far too much data: $url2= file_get_contents("$url2"); echo "$url2<br><br>";Is there an easy way for me to reduce it to only the data that I require from the remote page?I have spent hours googling for a solution, however, nothing appears to be working for me.Regards,Aaron Quote Link to comment https://forums.phpfreaks.com/topic/288315-get_file_contents-returning-too-much-data/ Share on other sites More sharing options...
ginerjm Posted May 7, 2014 Share Posted May 7, 2014 You've spent hours googling for a solution? Did you happen to try looking up the function definition in the PHP manual? Depending upon what you mean by "returning far too much data", you can control that amount with this function's arguments. But of course - how do you determine how much data you DO want returned? Is it a constant all the time? Is it only the beginning or nearly at the end? Or is it bytes 100 - 299? It appears you are going to be reading urls - can you be sure that the contents of that url doesn't change or are you going to be using logic to do searches or pattern matches to locate the specific data you want? Really a complex issue, but controlling how much data is returned is definitely simple and up to you. Quote Link to comment https://forums.phpfreaks.com/topic/288315-get_file_contents-returning-too-much-data/#findComment-1478591 Share on other sites More sharing options...
QuickOldCar Posted May 7, 2014 Share Posted May 7, 2014 since you seem to be wanting to display the entire contents, why not just iframe it instead Specify what type of data you want from it, is various ways to get data from a site. dom , simplexml , simple_html_dom , curl and use preg_match , preg_match_all with some regex You need to show us the page or an example of the results, and what info you would want from it. And also sites don't usually like other sites using their data, so ask them first, maybe they even have an api to get the data easier. Quote Link to comment https://forums.phpfreaks.com/topic/288315-get_file_contents-returning-too-much-data/#findComment-1478645 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.