petermr / pygetpapers

a Python version of getpapers
Apache License 2.0
78 stars 9 forks source link

EPMC does not offer ZipFile #18

Closed petermr closed 3 years ago

petermr commented 3 years ago
(base) pm286macbook:PMC_download_test pm286$ pygetpapers -q PMC7400000 -z -o MDPI_project
INFO: Total Hits are 1
WARNING: Could not find more papers
Traceback (most recent call last):
  File "/opt/anaconda3/bin/pygetpapers", line 8, in <module>
    sys.exit(main())
  File "/opt/anaconda3/lib/python3.8/site-packages/pygetpapers/pygetpapers.py", line 603, in main
    callpygetpapers.handlecli()
  File "/opt/anaconda3/lib/python3.8/site-packages/pygetpapers/pygetpapers.py", line 586, in handlecli
    self.apipaperdownload(args.query, args.limit,
  File "/opt/anaconda3/lib/python3.8/site-packages/pygetpapers/pygetpapers.py", line 377, in apipaperdownload
    self.makexmlfiles(read_json, getpdf=getpdf, makecsv=makecsv, makexml=makexml, makehtml=makehtml,
  File "/opt/anaconda3/lib/python3.8/site-packages/pygetpapers/pygetpapers.py", line 260, in makexmlfiles
    self.download_tools.getsupplementaryfiles(
  File "/opt/anaconda3/lib/python3.8/site-packages/pygetpapers/download_tools.py", line 337, in getsupplementaryfiles
    z = zipfile.ZipFile(io.BytesIO(r.content))
  File "/opt/anaconda3/lib/python3.8/zipfile.py", line 1268, in __init__
    self._RealGetContents()
  File "/opt/anaconda3/lib/python3.8/zipfile.py", line 1335, in _RealGetContents
    raise BadZipFile("File is not a zip file")
zipfile.BadZipFile: File is not a zip file

This file has no Figures but it has 6 tables. Clearly we have to trap Zero figures.

In general you can expect every extreme condition to occur!