Wikipedia
Wikipedia copied to clipboard
The sections attribute is an empty list.
The example page, where I've noticed the issue: Comparison of MUTCD-Influenced Traffic Signs
Here's what's happening:
import wikipedia
mutcd = wikipedia.page('Comparison of MUTCD-Influenced Traffic Signs')
mutcd.sections
Which outputs []
.
I would expect the section headers from the ToC to appear in the list as mentioned in the documentation. Let me know if I'm just doing it wrong!
Hi
I think this fixes it. Replace line 646 from wikipedia.py
as follows:
query_params.update({'page': self.title})
Apparently the previous thing was essentially returning a dictionary {'titles': self.title}
and titles was not a valid call in the API.
Here is an example -- http://en.wikipedia.org/w/api.php?action=parse&prop=sections&page=MATLAB
I'm going to make a pull request now.
@makarandtapaswi I checked your pull request and I believe the attr check was necessary. Other than that, I made the exact same change. Feel free to try another pull request with my code if you want.
Any news regarding this issue? Has it been fixed and it will be included in the next release? Do you know if there is any workaround for the actual release?
Is this fix going to be moved to the main branch?
It has been well over two years since this bug was reported and fixed by different people. This is a serious bug affecting the most basic uses of the API. Will any of the fixes be merged into master?
@goldsmith can you please merge? :)
I was facing the same issue. And since it's almost 3 years and it doesn't look, that it will get fixed, I have created another simple library - Wikipedia-API
import wikipediaapi
wiki = wikipediaapi.Wikipedia('en')
mutcd = wiki.page('Comparison of MUTCD-Influenced Traffic Signs')
print("\n".join([s.title for s in mutcd.sections]))
Output:
Differences between MUTCD-influenced traffic signs
Table of traffic signs comparison
See also
Notes
update on makarandtapaswi recommended changes. This still works but wikipedia.py line 646 shows:
query_params.update(self.__title_query_param) change to query_params.update({'page': self.title})