Parsing SHOUTcast server information table with Ja

2019-02-26 04:10发布

问题:

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.