Page 1 of 1

fopen of working URL fails

Posted: Tue Apr 22, 2003 6:23 am
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?

:?:

Posted: Tue Apr 22, 2003 6:35 am
by McGruff
Just guessing but could it be that fopen can't open a stream on a dynamically generated page?

Posted: Tue Apr 22, 2003 7:52 am
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.

Posted: Wed Apr 23, 2003 6:11 am
by eeRuheeRu
try fsockopen instead of fopen

Posted: Wed Apr 23, 2003 6:50 am
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.

Posted: Wed Apr 23, 2003 10:09 am
by patrikG
There is a handy open source class for difficult URLs:

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

Good luck.