Wikipedia icon indicating copy to clipboard operation
Wikipedia copied to clipboard

The sections attribute is an empty list.

Open radicalbiscuit opened this issue 10 years ago • 8 comments

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!

radicalbiscuit avatar Dec 12 '14 17:12 radicalbiscuit

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 avatar Feb 18 '15 15:02 makarandtapaswi

@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.

lucas-tulio avatar Apr 02 '15 22:04 lucas-tulio

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?

foebu avatar May 04 '15 09:05 foebu

Is this fix going to be moved to the main branch?

davidjmerritt avatar Nov 27 '16 04:11 davidjmerritt

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?

nachogoro avatar Aug 24 '17 07:08 nachogoro

@goldsmith can you please merge? :)

arjunkalburgi avatar Dec 03 '17 05:12 arjunkalburgi

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

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

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})

TrevorC85 avatar Jul 12 '19 21:07 TrevorC85