问题
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.
回答1:
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");
回答2:
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.
回答3:
CURLOPT_PORT
Needs to be set to the appropriate port perhaps~
来源:https://stackoverflow.com/questions/5136712/reading-html-file-from-url