Reputation: 103
The folowing code gives me PageError
print(wikipedia.summary("Bill Gates", sentences=2))
PageError: Page id "bill gets" does not match any pages. Try another id!
Upvotes: 2
Views: 388
Reputation: 1150
That is because the summary
function expects an id of a page, not just a random name.
I would assume that the page id is the same as the part behind /wiki/
in the link if you go to the Wikipedia page. In Bill Gate's case, the url is https://en.wikipedia.org/wiki/Bill_Gates
.
This probably means that the id of this page is Bill_Gates
.
So this probably works:
print(wikipedia.summary("Bill_Gates", sentences=2))
Upvotes: 2
Reputation: 6735
If you surround the query in single quotes, it should use the literal string:
from mediawiki import MediaWiki
wikipedia = MediaWiki()
print(wikipedia.summary("'Bill Gates'", sentences=2))
William Henry Gates III (born October 28, 1955) is an American business magnate, software developer, and philanthropist. He is best known as the co-founder of Microsoft Corporation.
Upvotes: 2