Reading HTML file from URL

428 views Asked by At

While most of the time I'd just use file_get_contents and CURL, I can't get it to work with a port in the URL. How can I read this file? http://174.120.124.178:7800/7.html (It's a shoutcast statistics file)

Ultimately, I just want the text after the last comma.

3

There are 3 answers

1
Matthew Flaschen On BEST ANSWER

It has nothing to do with the port. They're blocking you because you're not using a browser user agent. curl does let you fake the user agent, but that may be a violation of the site's terms of service.

According to this post it's not about blocking scripts, but just distinguishing between Shoutcast clients and everything else. So the code is:

curl_setopt($curl_handle, CURLOPT_USERAGENT, "Mozilla");
1
Jeremiah Willcock On

I tried to download your file with Curl on the command line and got a 404 error; it does load with Firefox and Lynx. This page says that you need to change the User-Agent string for it to download.

0
Shad On

CURLOPT_PORT Needs to be set to the appropriate port perhaps~