Cómo encontrar el PDF gratuito de un artículo científico a partir de su DOI
Tienes un DOI, la página de la editorial pide iniciar sesión y solo necesitas leer la sección de métodos. Muy a menudo existe una copia gratuita y legal en algún sitio: el repositorio de la universidad del autor, un preprint, PubMed Central. Buscarla a mano obliga a probar cuatro o cinco webs. Hacerlo desde código requiere un puñado de APIs públicas llamadas en un orden razonable. El orden que…
Finding free PDF versions of scientific articles using their DOI involves several steps and potential sources. Often, a free copy of the article can be found in one of four places: the author's university repository, a preprint server, PubMed Central, or another freely available site. Searching for these copies manually can require trying out four or five websites.
Automating this process can be done using open APIs, usually starting with the Paper Space in the osFoundry desktop application, which tests each source one by one until it finds a legitimate PDF. The backend of this application attempts each source in turn until one successfully returns a PDF.
For example, using the DOIs 10.1037/tmb0000123 and 10.1086/691462, one can query OpenAlex for all locations where the articles are hosted and whether each location has a direct PDF. For the meta-analysis article, it returns three locations: a publisher link, a copy at James Cook University's repository, and a landing page on Singapore Management University's library.
For the Brain Drain article, it indicates that the article is openly available (is_oa: true) and has a green OA status, but all PDF URLs are null. This means that while a free version exists somewhere, it doesn't provide a direct link to download it.
To obtain the PDF, the application then checks each location's PDF URL. However, these links are often protected by cookies, anti-bot checks, or login screens, and usually only return a 200 status code with HTML content, not the actual PDF. The Rust code behind the app only allows a download if the body of the response starts with the magic PDF signature (%PDF-). If the body doesn't match, the app records that the link was a web page, not a PDF, and moves on to the next link.
This logic can also be implemented in Python using only the standard library. The Python function `get()` fetches the content from a given URL with a 30-second timeout. The `pdf_links()` function queries OpenAlex for a work's best open access location and a list of all locations, then checks each for a `pdf_url`. Only the first four URLs are checked to save time.
The `first_real_pdf()` function uses `pdf_links()` to get a list of potential PDF URLs and attempts to fetch each, returning the first valid PDF. If no PDF is found after checking the first four URLs, a `LookupError` is raised indicating that no free PDF was found.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.