Custom PDF Resolvers

Custom resolvers forPDF retrievalcurrently can be configured via the188BET靠谱吗extensions.zotero.findPDFs.resolvershidden pref (Advanced preferences → Config Editor).The value should be a JSON string containing an array of configuration objects.HTMLand JSON sources are supported.

188BET靠谱吗You may wish to distribute a custom resolver using a Zotero plugin that adds or updates the pref at startup.

{     "name": "My Paper Source",     "method": "GET",     "url": "https://example.com/{doi}",     "mode": "html",     "selector": "#pdf-link",     "attribute": "href",     "automatic": false }

selectoris aCSS-style selector.Ifattributeis omitted, the element'stextContentis used.indexcan be passed to select a specific element of a set.

Ifautomaticisfalseor unspecified, the resolver will be used only for manual actions — Add Item by Identifier and Find Available PDFs — and not when saving from the browser.

Example: Extract PDF URLs from a JSON API

Note:The UnpaywallAPI188BET靠谱吗is used here for demonstration purposes, but Zotero already uses its own mirror of Unpaywall data, so configuring it with a custom resolver isn't necessary.

{     "name": "Unpaywall",     "method": "GET",     "url": "https://api.unpaywall.org/v2/{doi}?email=me@example.com",     "mode": "json",     "selector": ".oa_locations.url_for_pdf",     "automatic": true }

selectorusesJSPathsyntax.

In this case,.oa_locations.url_for_pdfmatches zero or moreURLstrings in theurl_for_pdfproperty in objects in theoa_locationsarray.

However, Unpaywall can return either direct PDF URLs or landing page URLs, so matching onurl_for_pdfalone isn't sufficient.For advanced cases like this, amappingsobject can be provided to pull out specific values:

{     "name": "Unpaywall",     "method": "GET",     "url": "https://api.unpaywall.org/v2/{doi}?email=me@example.com",     "mode": "json",     "selector": ".oa_locations",     "mappings": {         "url": "url_for_pdf",         "pageURL": "url_for_landing_page"     },     "automatic": true }

Here, theoa_locationsarray is matched directly, andmappingsis used to assign theurl_for_pdfandurl_for_landing_pageproperties from the array objects tourl(for a direct PDF link) andpageURL(for a page where a PDF can be translated).

kb/custom_pdf_resolvers.txt· Last modified: 2024/07/26 03:38 by dstillman
Baidu
map