문제

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?

도움이 되었습니까?

해결책

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());

다른 팁

You use the "parse" action of the MediaWiki API assuming you want the HTML:

http://en.wiktionary.org/w/api.php?action=parse&page=bicycle&prop=text&disablepp=1&format=json

If you were looking for the original wikitext you just request a different property:

http://en.wiktionary.org/w/api.php?action=parse&page=bicycle&prop=wikitext&disablepp=1&format=json

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top