Using The Ruby Racer to evaluate HTML with embedded JavaScript

61 views
Skip to first unread message

Steven Noble

unread,
Oct 29, 2014, 11:10:09 PM10/29/14
to therub...@googlegroups.com
I'd like to feed The Ruby Racer a string that looks like, say, this:

<html>
  <body>
    <script>
      document.write("Hello World");
    </script>
  </body>
</html> 

...and, in that case, get back a string that looks like this:

<html>
  <body>
    Hello World
  </body>
</html>

Is that possible? It's not obvious to me from the docs.

Many thanks,

Steven.

Charles Lowell

unread,
Oct 30, 2014, 3:05:40 PM10/30/14
to Steven Noble, therub...@googlegroups.com
Steven,

The ruby racer only embeds a javascript interpreter. It does not parse DOM. You’re probably better off with PhantomJS if you want to deal with full HTML documents server side.

cheers,
Charles

--
You received this message because you are subscribed to the Google Groups "The Ruby Racer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to therubyracer...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages