goldsmith / Wikipedia

A Pythonic wrapper for the Wikipedia API
https://wikipedia.readthedocs.org/
MIT License
2.88k stars 520 forks source link

Library not returning sections #119

Open mcat-ee opened 8 years ago

mcat-ee commented 8 years ago

I've just installed the Wikipedia library and it's returning various other aspects of a page (e.g. summary, references) but not the sections. It doesn't even return None, it simply returns an empty list object.

Has this been encountered before?

My current code for replicating this error is as follows: page = wikipedia.page("FN-6") print page.sections

mcat-ee commented 8 years ago

Okay, it seems that the library is accidentally parsing the 'Edit' part of a section heading as part of the heading.

See attached image for an example of this.

image

barrust commented 8 years ago

This has to do with the query parameters not being correct for when the page is title based. In a fork of this code base I fixed the issue (https://github.com/barrust/Wikipedia) since this one hasn't been updated in awhile. To fix it I changed:

query_params.update(self.__title_query_param)

to

if not getattr(self, 'title', None):
    query_params['pageid'] = self.pageid
else:
    query_params['page'] = self.title
anisayari commented 6 years ago

I got a sililar issue with sections in python 3.6 : page.sections returning always an empty list.

import wikipedia
page = wikipedia.page(pageid=21055())
print(page.sections)
#[]
barrust commented 6 years ago

@anisayari This repo doesn't seem to be maintained any more. The empty sections is a common issue in the issues log (#77 #95 #168 #119) As such, about a year ago I wrote a re-write fork of this library (https://github.com/barrust/mediawiki) that aims to support multiple mediawiki sites and not just Wikipedia. Hope this helps!

anisayari commented 6 years ago

Thank you @barrust , I am gonna take a look to your fork. (I hope this repo will be maintained, because it's a useful project.)

kaleidawave commented 6 years ago

Can confirm @barrust fork of the libary fixes this sections issue

mcat-ee commented 6 years ago

hey @goldsmith - could you merge the pending PRs?

johann-lau commented 3 years ago

Still no sections here

stedf commented 2 years ago

@johann-lau

as today if I use: pip3 install wikipedia sections still returns an empty list, while is possible to call the single sections by section name.

if i use: pip3 install git+https://github.com/goldsmith/Wikipedia everything seems to be working fine

kanjurer commented 3 months ago

pip3 install git+https://github.com/goldsmith/Wikipedia gives me an installation error

stedf commented 2 months ago

pip3 install git+https://github.com/goldsmith/Wikipedia gives me an installation error instead of giving thumbs down, why don't you share what error you get ?

kanjurer commented 2 months ago

pip3 install git+https://github.com/goldsmith/Wikipedia


Collecting git+https://github.com/goldsmith/Wikipedia
Cloning https://github.com/goldsmith/Wikipedia to c:\users\kanav\appdata\local\temp\pip-req-build-tfdd_w6k
Running command git clone --filter=blob:none --quiet https://github.com/goldsmith/Wikipedia 'C:\Users\kanav\AppData\Local\Temp\pip-req-build-tfdd_w6k'
Resolved https://github.com/goldsmith/Wikipedia to commit 1554943e8ab463cef5e93081def48fafbdef324e
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error

× python setup.py egg_info did not run successfully. │ exit code: 1 ╰─> [6 lines of output] Traceback (most recent call last): File "", line 2, in File "", line 34, in File "C:\Users\kanav\AppData\Local\Temp\pip-req-build-tfdd_w6k\setup.py", line 19, in version = re.search( AttributeError: 'NoneType' object has no attribute 'groups' [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed

× Encountered error while generating package metadata. ╰─> See above for output.

note: This is an issue with the package mentioned above, not pip. hint: See above for details.