Page 1 of 1

Problems getting URL with file_get_contents

Posted: Sat Mar 08, 2008 5:57 am
by madhapee
hello :)

over the last 8 weeks I have been diving into the world of php and I love it.
I have a background working with Perl and find it fun to use it on the web.

I was trying to parse a website and the file_get_contents function refuses to return the URL that I wish to parse.

The code is very simple:

$source = "http://quicktake.morningstar.com/FundNe ... mbol=VIIIX";
$source = urlencode($source);
$handle = file_get_contents($source);
print_r($handle);


This has worked for me for other URLs but this particular one does not want to load in.

Any clues to what I am doing wrong?
Is there a clear rule(or function) to know what URLs can be parsed and which ones cannot?

thanks so much.

Re: Problems getting URL with file_get_contents

Posted: Sat Mar 08, 2008 6:28 am
by bertfour
Maybe the morningstar checks for user agents?

If a client doesn't show a valid browser type, then go away....

Re: Problems getting URL with file_get_contents

Posted: Sat Mar 08, 2008 7:35 am
by madhapee
mmm... I do run this script from the firefox browser, would that not make my user agent to be firefox?

Re: Problems getting URL with file_get_contents

Posted: Sat Mar 08, 2008 7:38 am
by bertfour
No.

Its the scripts user agent, probably non-existent.

It is possible to mimic a browser, but in this case it would be sort of illegal....