The analysis of exoplanetary atmospheres by means of high-resolution spectroscopy is an expanding research field which provides information on chemical composition, thermal structure, atmospheric dynamics and orbital velocity of exoplanets. In this work, we aim at the detection of the light reflected by the exoplanet 51~Peg~b employing optical high-resolution spectroscopy. To detect the light reflected by the planetary dayside we use optical HARPS and HARPS-N spectra taken near the superior conjunction of the planet, when the flux contrast between the planet and the star is maximum. To search for the weak planetary signal, we cross-correlate the observed spectra with a high S/N stellar spectrum. We homogeneously analyze the available datasets and derive a $10^{-5}$ upper limit on the planet-to-star flux contrast in the optical. The upper limit on the planet-to-star flux contrast of $10^{-5}$ translates into a low albedo of the planetary atmosphere ($rm A_glesssim0.05-0.15$ for an assumed planetary radius in the range $rm 1.5-0.9~R_{Jup}$, as estimated from the planets mass).