javamediawikiwikiwiktionary

How do I get Html Source of a Wiktionary page?


I am struggling withe Wiki Api. How can I simply get a pages html using the API. I know it is possible as I have done it before but I cannot remember how to do it.

Say I want the page source for the page http://en.wiktionary.org/wiki/bicycle how do I do it. What API do I use. I do not want to look in the Browser?


Solution

  • With Java and Jsoup you can do this:

    Document document = Jsoup
            .connect("http://en.wiktionary.org/wiki/bicycle")
            .get();
    
    Element bodyContent = document.select("div#bodyContent").first();
    
    System.out.println(bodyContent.html());