Wikipedia icon indicating copy to clipboard operation
Wikipedia copied to clipboard

How to get the URL of the returned simple summary?

Open technolingo opened this issue 8 years ago • 3 comments

For instance:

info = wikipedia.summary("Facebook", sentences=5)
url = ?

Thank you!

technolingo avatar Nov 20 '17 05:11 technolingo

You can try to migrate to Wikipedia-API. It's very straightforward.

import wikipediaapi
wiki = wikipediaapi.Wikipedia('en')
p = wiki.page('Facebook')
print(p.fullurl)
print(wiki.extracts(p, exsentences=2))

Outputs

https://en.wikipedia.org/wiki/Facebook
Facebook, Inc. is an American online social media and social networking service company.

martin-majlis avatar Dec 13 '17 13:12 martin-majlis

I think if you use .page(), it will load more data than simply using .summary(). Not sure.

technolingo avatar Dec 19 '17 05:12 technolingo

@evilplanet There is a preload argument in the page method of the Wikipedia module. If it is set to True, only then the entire page is obtained by default. Else, I think the summary will be obtained only when the summary method is called (see this code for more info).

esh-b avatar Apr 17 '18 19:04 esh-b