Astrocook is a new Python package to analyze the spectra of quasi-stellar objects (QSOs) from the near-UV band to the near-infrared band. The project stems from the lessons learned in developing the data analysis software for the VLT ESPRESSO spectrograph. The idea is to leverage numerical libraries like SciPy, NumPy, and Lmfit and astronomical libraries like Astropy to produce a collection of high-level recipes capable of interpreting the features observed in QSO spectra (such as the emission continuum and the absorption systems) in an automated and validated way. The package provides great flexibility in designing the operational workflow, as well as a set of interactive tools to apply the recipes in a seamless way. The aim is to achieve the combination of accuracy, stability, and repeatability of the procedure that is required by several compelling science cases in the era of "precision cosmology" (e.g. the measurement of a possible variability in the value of fundamental constants, and the direct measurement of the accelerated expansion of the Universe).