Jump to content

get_file_contents returning too much data


MorphixNW

Recommended Posts

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

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.