Getting both page id and snippet from Wikipedia

Getting both page id and snippet from Wikipedia
0

#1

Hi there :slight_smile:

Is there a way to fetch both page id and text snippet from Wikipedia? generator=search has this parameter called gsrprop that supposedly has snippet as a possible value, but I don’t see any snippet in the data I get.

I could probably add list=search then use srprop to get the text snippets but I feel there’s a better way to do this.

Thanks! :smiley:


#2

ye the wiki api has a lot of confusing info to understand and like yourself im working on these problems … at the moment i can send search request and get back page link and text and page name. last night found another way as i wanted some thumbnail images as well and from looking at it it also supplies page id and text snippet so think it should help you out. im giving you a link to a wiki page
in the section …Querying query results in one request you will find a useful link that returns the info you are looking for
also after you run linkwhich youll find from this link page… (i copied and pasted it into another window, it returns in xml format … you will need to add a … format=json to the link to work with)
https://www.mediawiki.org/wiki/API:Page_info_in_search_results

look through the string and gpslimit=10 change to 1 as this will make it easier to break down the returned result for you to figure out how to get what you need and see if it is suitable for you.
There is so much info on wiki for the api it is tough going trying to figure out how to put the search query together … i looked at lots of pages and tried using the sandbox and read a lot of stackover flow answers … but im getting sorted slowly… im trying to make a predictive wiki search and so far it works … just wasnt getting any thumbnails so with this link i should be able to sort that part out. anyway good look with your project.