Problems getting URL with file_get_contents

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
madhapee
Forum Newbie
Posts: 2
Joined: Sat Mar 08, 2008 5:52 am

Problems getting URL with file_get_contents

Post 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.
bertfour
Forum Commoner
Posts: 45
Joined: Fri Mar 07, 2008 7:33 am

Re: Problems getting URL with file_get_contents

Post by bertfour »

Maybe the morningstar checks for user agents?

If a client doesn't show a valid browser type, then go away....
madhapee
Forum Newbie
Posts: 2
Joined: Sat Mar 08, 2008 5:52 am

Re: Problems getting URL with file_get_contents

Post by madhapee »

mmm... I do run this script from the firefox browser, would that not make my user agent to be firefox?
bertfour
Forum Commoner
Posts: 45
Joined: Fri Mar 07, 2008 7:33 am

Re: Problems getting URL with file_get_contents

Post 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....
Post Reply