DEV Community

Cover image for How to get a summary of the a page in Wikipedia?🤔
Phoenix
Phoenix

Posted on

How to get a summary of the a page in Wikipedia?🤔

Hi, friends!

You Can use the Wikipedia API for this work;

Look this Code:

import requests as rq

Query = "iran"#What Do You Want To Search In wikipedia
Lang = "en"#Your Language
Url = f"https://{Lang}.wikipedia.org/api/rest_v1/page/summary/{Query}"

Result = rq.get(Url).json()['extract']

print(str(Result))
Enter fullscreen mode Exit fullscreen mode

Run and See The Result.

Do not forget to like!
Bye until the next post👋

Oldest comments (1)

Collapse
 
david050708 profile image
david050708

Nice one
Actually you can use the Wikipedia module in python, it has a built in feature for summaries