Changing href atributes with nokogiri and ruby on rails
- by fool
Hi,
I Have a HTML document with links links, for exemple:
<html>
<body>
<ul>
<li><a href="http://someurl.com/etc/etc">teste1</a></li>
<li><a href="http://someurl.com/etc/etc">teste2</a></li>
<li><a href="http://someurl.com/etc/etc">teste3</a></li>
<ul>
</body>
</html>
I want with Ruby on Rails, with nokogiri or some other method, to have a final doc like this:
<html>
<body>
<ul>
<li><a href="http://myproxy.com/?url=http://someurl.com/etc/etc">teste1</a></li>
<li><a href="http://myproxy.com/?url=http://someurl.com/etc/etc">teste2</a></li>
<li><a href="http://myproxy.com/?url=http://someurl.com/etc/etc">teste3</a></li>
<ul>
</body>
</html>
What's the best strategy to achieve this?