fopen of working URL fails

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
lvzrdoz
Forum Newbie
Posts: 7
Joined: Sun Feb 09, 2003 12:38 am
Location: Las Vegas

fopen of working URL fails

Post by lvzrdoz »

I'm trying to read a webpage to extract some video links. When I try to fopen the URL, it fails:

$fp=fopen("http://msnbc.com/news/NIGHTLYTB_Front.asp","rb");

Warning: fopen(http://msnbc.com/news/NIGHTLYTB_Front.asp) [function.fopen]: failed to create stream: Invalid argument in /home/itvfan/public_html/tv/tv_nbc.php on line 11

This is the first working URL that has failed like this. Anyone know why or have an alternate solution?

:?:
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

Just guessing but could it be that fopen can't open a stream on a dynamically generated page?
lvzrdoz
Forum Newbie
Posts: 7
Joined: Sun Feb 09, 2003 12:38 am
Location: Las Vegas

Post by lvzrdoz »

Pending a more elegant solution, I'm going to use a Linux kludge:

$result = shell_exec("wget -q -O - $url");

This works but it is not the best solution.
eeRuheeRu
Forum Newbie
Posts: 3
Joined: Wed Dec 11, 2002 2:46 am
Location: Estonia

Post by eeRuheeRu »

try fsockopen instead of fopen
lvzrdoz
Forum Newbie
Posts: 7
Joined: Sun Feb 09, 2003 12:38 am
Location: Las Vegas

Post by lvzrdoz »

That was one of the first things I tried. Basically same results.

Since I can fopen all other webpages I've tried, there must be something the ASP page is doing (such as requiring specific browser clients) that fopen and fsockopen can't do by themselves.
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

There is a handy open source class for difficult URLs:

http://sourceforge.net/projects/snoopy/

Good luck.
Post Reply