用Javascript解析SHOUTcast服务器信息表?
我目前正在尝试解析html页面 http://84.19.184.204:8000/played.html< /a> 使用 JS。
但这很难,因为我是 JS 新手...html 页面包含一个表格,其中包含上次播放歌曲的历史记录...这个列表就是我想要解析的内容。
我使用 XMLHttpRequest()
但我不明白如何解析元素:(
有人可以帮助我吗?
I'm currently trying to parse the html page http://84.19.184.204:8000/played.html using JS.
But it's been hard since I'm new to JS... The html page contains a table which has the history of last played songs... This list is what I want to parse.
I use XMLHttpRequest()
but I can't understand how to parse the elements :(
Can someone help me out?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
忘记这一点,只需获取 XML 版本即可。使用此 URL:
http://84.19.184.204:8000/admin.cgi ?pass=YOURADMINPASSWORD&mode=viewxml
您正在查找
区域。此外,如果您计划在网站上使用此文件,则需要设置服务器端代理才能访问此文档。有数百种方法可以执行此操作,因此,如果您不确定如何操作,请创建一个新问题来询问此问题,并详细说明您正在使用的服务器端语言。这就是解决跨站点脚本的方法。
Forget that, just get the XML version. Use this URL:
http://84.19.184.204:8000/admin.cgi?pass=YOURADMINPASSWORD&mode=viewxml
You're looking for the
<SONGHISTORY>
area.Also, if you do plan on using this on a website, you will need to set up a server-side proxy to access this document. There are a few hundred ways to do this, so if you aren't sure how, create a new question asking this, with details about what server-side language you are using. This is how you get around cross-site scripting.
鉴于 Shoutcast
played.html
页面布局的静态性质,正则表达式可能是提取信息的最佳选择。但是,请参阅我对您的问题的评论,了解为什么在 JavaScript 中执行此操作可能不是一个好主意。Given the static nature of the layout of Shoutcast
played.html
pages, a regular expression would probably be the best choice to extract information. However, see my comment to your question as to why doing this in JavaScript might not be a good idea.