如何获取shoutcast源代码?
我想从喊话中获取源代码。我读了下面的代码行:
try {
URL game = new URL("http", "somewebsitename", 8013, "index.html");
URLConnection connection = game.openConnection();
BufferedReader in = new BufferedReader(new
InputStreamReader(connection.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
System.out.println(inputLine);
}
in.close();
} catch (Exception e) {
e.printStackTrace();
}
而不是获取我在 Chrome、Firefox 或 Internet Explorer 中看到的源代码,而是得到了这些行:
ICY 404 Resource Not Found icy-notice1:
SHOUTcast 分布式网络音频服务器/Linux v1.9.8
icy-notice2:找不到请求的资源
我确保该文件存在于服务器上。
I want to get the source code from a shoutcast. I read the lines with the code below:
try {
URL game = new URL("http", "somewebsitename", 8013, "index.html");
URLConnection connection = game.openConnection();
BufferedReader in = new BufferedReader(new
InputStreamReader(connection.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
System.out.println(inputLine);
}
in.close();
} catch (Exception e) {
e.printStackTrace();
}
Instead of getting the source code which I see with Chrome, Firefox or Internet Explorer I get these lines:
ICY 404 Resource Not Found
icy-notice1:
SHOUTcast Distributed Network Audio Server/Linux v1.9.8
icy-notice2:The resource requested was not found
I made sure the the file exists on the server.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我假设“从 SHOUTcast 获取源代码”是指您想要从 SHOUTcast 管理面板页面获取 HTML。
如果您需要管理面板,则需要在用户代理字符串中包含
Mozilla
。一旦你正确设置了你的用户代理,你就不会有问题了。另请参阅:设置 java URLConnection 的用户代理
I assume by "get the source code from a shoutcast" you mean you want to get the HTML from a SHOUTcast Admin Panel page.
If you want the admin panel, you need to have
Mozilla
somewhere in your User-Agent string. Once you set your User-Agent appropriately, you'll have no problem.See also: Setting user agent of a java URLConnection