paper_retriever
Download a single paper by DOI/PMID.
pypaperretriever.paper_retriever.PaperRetriever
PaperRetriever(
email,
doi=None,
pmid=None,
allow_scihub=False,
download_directory="PDFs",
filename=None,
override_previous_attempt=False,
)
Find and download scientific papers.
The class queries several services (Unpaywall, PubMed Central, Crossref and optionally Sci-Hub) to locate a PDF for a given DOI or PMID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
email
|
str
|
Email address used for API requests. |
required |
doi
|
str
|
Digital Object Identifier of the paper. |
None
|
pmid
|
str
|
PubMed identifier of the paper. |
None
|
allow_scihub
|
bool
|
Whether to query Sci-Hub as a fallback. |
False
|
download_directory
|
str
|
Directory where PDFs are stored. |
'PDFs'
|
filename
|
str
|
Custom filename for the downloaded PDF. |
None
|
override_previous_attempt
|
bool
|
Overwrite existing downloads. |
False
|
Attributes:
Name | Type | Description |
---|---|---|
doi |
str
|
DOI encoded for safe file paths. |
pmid |
str | None
|
PubMed ID of the paper. |
pdf_urls |
list[str]
|
Candidate URLs pointing to PDF files. |
filepath |
str | None
|
Path to the downloaded PDF if successful. |
is_downloaded |
bool
|
|
is_oa |
bool
|
|
on_scihub |
bool
|
|
Source code in pypaperretriever/paper_retriever.py
download
Find and download the paper.
The method queries multiple services for PDF links and attempts to download the first accessible file. Metadata about the attempt is stored alongside the PDF.
Returns:
Name | Type | Description |
---|---|---|
Self |
Self
|
This instance. |
Source code in pypaperretriever/paper_retriever.py
check_open_access
Check Unpaywall for open-access availability.
Updates pdf_urls
with any links returned by the API and sets
is_oa
if open-access links are found.
Returns:
Name | Type | Description |
---|---|---|
Self |
Self
|
This instance. |
Source code in pypaperretriever/paper_retriever.py
check_pubmed_central_access
Check whether the article is available in PubMed Central.
Any discovered PDF links are appended to pdf_urls
.
Returns:
Name | Type | Description |
---|---|---|
Self |
Self
|
This instance. |
Source code in pypaperretriever/paper_retriever.py
check_crossref_access
Query Crossref for PDF links.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
doi
|
str
|
DOI to query. |
required |
Returns:
Name | Type | Description |
---|---|---|
Self |
Self
|
This instance. |
Source code in pypaperretriever/paper_retriever.py
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
|
check_scihub_access
Search Sci-Hub mirrors for the paper.
Introduces small delays and rotates user agents to reduce the likelihood of being blocked.
Returns:
Name | Type | Description |
---|---|---|
Self |
Self
|
This instance. |
Source code in pypaperretriever/paper_retriever.py
CLI entry point
pypaperretriever.paper_retriever.main
Run the command-line interface.
The interface accepts DOI or PMID identifiers and downloads the
corresponding PDFs using :class:PaperRetriever
.