can we get the desired portion from the wiktionary api?
I'm using the wiktionary api to get information from the wiktionary.org..
I'm getting the data in the json format开发者_如何学C and i'm able to parse it too...
but i want to remove some portion of data from the result (in fact, i need only some data), but i dont how to remove certain content from the result..
the code i'm using is
<script type="text/javascript" src="./jquery-1.4.3.min.js"></script>
<div id="wikiInfo"> contents</div>
<script type="text/javascript">
$.getJSON('http://en.wiktionary.org/w/api.php?action=parse&page=acting&format=json&prop=text&callback=?',
function(json) {
$('#wikiInfo').html(json.parse.text.*);
$("#wikiInfo").find("a:not(.references a)").attr("href", function(){
return "http://sample.com/" + $(this).attr("href");});
$("#wikiInfo").find("a").attr("target", "_blank"); }
);
</script>
the above code renders the data as in the following page..
http://englishore.com/parse-wiki.php
But i need to scrap the Pronunciation and Translations portion from the result..
how can i do that?
Please do not forget to include license information. I created a full working example at https://gist.github.com/674522, feel free to reuse the code. Beside the wrong selector, already mentioned by lonesomeday, the modification of href attributes did not catch all cases, so I fixed it.
You are trying to use json.parse.text.*
to access the relevant part of the object. This is not valid JS syntax -- you can't use *
in an array property. You'll have to use array-style syntax instead:
$('#wikiInfo').html(json.parse.text['*']);
精彩评论