i am looking for an html parser that can search and replace the anchor tags like
ex
<a href="/ima/index.php">example</a>
to
<a href="http://www.example.com/ima/index.php">example</a>
UPDATED:
my code with jsoup but not working
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import com.google.common.collect.ImmutableList;
import com.google.common.net.InternetDomainName;
public class test {
public static void main(String args[]) throws IOException {
Document doc = Jsoup.connect("http://www.google.com").get();
String html =doc.outerHtml().toString();
// System.out.println(html);
Elements links = doc.select("a");
for (Element link : links) {
String href=link.attr("href");
if(href.startsWith("http://"))
{
}
else
{
html.replaceAll(href,"http://www.google.com"+href);
}
}
System.out.println(html);
}
}
<BASE HREF='http://www.example.com/'>to achieve this result? Or are you looking to override the contents of a site?