Wikipedia Search using Wikipedia API and Web Component

475 views
Skip to first unread message

SteveJG

unread,
Dec 17, 2017, 3:42:59 PM12/17/17
to MIT App Inventor Forum

The Web object and the Wikipedia API can search Wikipedia topics together.  The example shows one way to handle a JSON list and parse its elements.  The &limit=8 requests that eight topics should be searched.  This could easily enough be 1 or 100, what you use depends on how you will use the search information.  The pairs block could be used to show the reference and the url link of the entire article.  A developer probably will not want to display the steps required as shown here:  select a topic, request a JSON search using a TextBox, parsing the resulting JSON retrieved using the Get component, placing the key information in a ListView etc.  Most will only want to show the listview and results in their app.

The required code blocks are provided in the attachment.


Merry Christmas, Wesołych Świąt,  Feliz Navidad, God Jul, Joyeux Noel, Καλά Χριστούγεννα, Happy Christmas, Veseloho Rizdva, Prettige Kerstdagen, Frohe Weihnachten!, 성탄 축하 , Buon Natale,  聖誕快樂 ,  圣诞快乐,  Sretan Božić, C рождеством!,  عيد ميلاد مجيد  

 Have a great holiday.

Steve
wikipediaAPI.png
Message has been deleted
Message has been deleted
Message has been deleted

SteveJG

unread,
Nov 20, 2018, 4:52:21 PM11/20/18
to mitappinv...@googlegroups.com
This is an app using the Wiki API  to search for topics.

Display Screen

wikiScreen.png


1) Type search criteria

2) Wait a few seconds (the search is set to search for a maximum of 100 references.  If there are fewer, the available references are displayed. The developer can change this maximum  in the getInfoFromWikipedia procedure and changing the &limit   value from 100 to something else.  Experiment to meet your requirements.  The larger the value, the longer it takes to populate the references (assuming there are at least as many references as specified in the &limit parameter).

3) When the ListView is populated, select a topic to display the Web page.  This too requires a few seconds to display. 

The search looks for a word or several words separated by spaces.  If nothing is found meeting that criteria, the app will let you know.

The app will not search for ISBN numbers and only searches Wikipedia documents.




App Inventor Blocks .. see attachment


API Documentation

https://www.mediawiki.org/wiki/API:Main_page





Merry Christmas 2018

Regards,
Steve
WikiipediaSearchResults_1_0.aia
wikiBlocks.png
Reply all
Reply to author
Forward
0 new messages