views:

95

answers:

1

Hi, I want to show lyrics for songs in my player. I used to use lyricsplugin.com because it had a lot of English and Russian lyrics, but recently they've changed their web-site from being a static page to an ajax-powered page. Searching lyrics follows this pattern:

http://www.lyricsplugin.com/winamp03/plugin/?artist=Linkin%20Park&title=Numb

It shows an empty page and this in body onload:

javascript:getContent('Linkin%20Park', 'Numb', '1281528101', '5e22e4e3979026a9af59ee16ff82fe1f')

while getContent looks like this:

function getContent(artist, title, time, check) { 
xmlHttp = GetXmlHttpObject();
if(xmlHttp == null)
{
    return;
}
var url = "content.php?artist=" + artist + "&title=" + title + "&time=" + time + "&check=" + check;
xmlHttp.onreadystatechange = stateChanged;
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
}

stateChanged() then puts response into corresponding div in the page.

So I guess I can download the page and build a DOM tree since it is XHTML. How do I use the built in rhino engine to execute the javascript and preferably override the stateChanged() function? I don't seem to be able to call that content.php script directly.

No other resource has that many lyrics (especially Russian) except for lyrics.wikia.com, but they don't allow screen scraping.

UPDATE:

lyricsplugin seems to be using justsomelyrics.com and there is a google custom search box. How can I access it from java?

Thank you.

A: 

The simplest is the SWT Browser component. Simply call setURL(String) and it will display the web page. This gives you a full fledged browser with Javascript and everything.

rancidfishbreath
Thanks, but I'm using Swing.
tulskiy