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πŸ‘‹

Top 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

Dream Big


Use any Linode offering to create something unique or silly in the DEV x Linode Hackathon 2022 and win the Wacky Wildcard category.

β†’ Join the Hackathon <-