I'm working on an e-commerce website using Power Reviews to manage product reviews. That service uses javascript to display the reviews on our webpages, which means the content is unlikely to be indexed by search engines. I'm trying to work around this so that the review content can be rendered server side, and therefore indexed.
Their script has two components that we place on our page. First, the script file is placed in the HEAD: http://cdn.powerreviews.com/repos/16238/pr/pwr/engine/js/full.js
Then we call the script where we want it to render HTML on the page, including the ID for the product:
POWERREVIEWS.display.engine(document, { pr_page_id : "product-id-here" });
My current theory is that I could set up a page that runs the javascript, then save the resulting page to a static HTML document. I could then pull that into the product page when it loads. This would need to be automated to update the HTML file for every product a couple of times per day, but there are only a couple dozen products, so I don't expect that to be too overwhelming on the server.
How would I do this? I haven't seen a good way to execute the javascript so I can save the output. Is there a better way to tackle this problem?
Thanks for your help.
OK... better answer.
The best solution that I could find is to use HtmlUnit http://htmlunit.sourceforge.net/ on the server to execute your html with the javascript and get back the final html that the user would see on the browser.
The library has good support for JavaScript and is headless so you should be able to run it on the server.
You would need to write a small Java wrapper that could accept input via the command line and pass it onto HtmlUnit for processing and then return the result to you. You could then call this wrapper from PHP.
See here: Execute javascript in PHP