How to download attachments with python

79 views
Skip to first unread message

Patrick Janssen

unread,
Apr 24, 2014, 8:11:14 PM4/24/14
to zoter...@googlegroups.com
Hi all,

I have been using pyzotero to download data from my zotero groups, which is working fine. But I can't seem to figure out how to download attachments. In particular, I have image attachments that I want to download.

I also had a look at libZotero, but also there I cannot see an api to download attachments.

Any suggestions?

Patrick

Patrick Janssen

unread,
Apr 24, 2014, 11:58:26 PM4/24/14
to zoter...@googlegroups.com
Hi all,

I think I I figured it out. I can do something like this:

urllib.retrieve("https://api.zotero.org/groups/GROUP_ID/items/ITEM_ID/file?key=MY_SECRET_KEY")

replacing GROUP_ID, ITEM_ID, and MY_SECRET_KEY with the appropriate strings

Let me know if there is a better way.

Patrick

Merul Patel

unread,
Sep 2, 2015, 11:42:29 AM9/2/15
to zotero-dev
Did this work for you? I get HTTP 403 Forbidden.

Best regards,

Merul

Stephan Hügel

unread,
Sep 2, 2015, 2:22:37 PM9/2/15
to zotero-dev
This is fairly straightforward using Pyzotero:

with open ('file.name', 'wb') as f:
    f.write(zot.file('itemkey'))

I've just pushed some changes (v1.1.12) that make it easier to write PDFs, in particular.
Reply all
Reply to author
Forward
0 new messages