Even though you prob don't care anymore, I had this problem and wanted to post in case anyone had the same problem.
Try 'page.replace' not 'page.replace_html'.
I guess replace_html is short for replace "inner" html, as that is what it does if you look up the documentation. I was debugging using netbeans and stepped into the replace_html method and that is what the nice comments said.