Parsing SHOUTcast server information table with Javascript?

烂漫一生 提交于 2019-12-02 03:36:39

问题


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?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/3696208/parsing-shoutcast-server-information-table-with-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!