Changing href atributes with nokogiri and ruby on rails
Posted
by fool
on Stack Overflow
See other posts from Stack Overflow
or by fool
Published on 2010-04-22T23:21:06Z
Indexed on
2010/04/22
23:23 UTC
Read the original article
Hit count: 323
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?
© Stack Overflow or respective owner