Metasurfaces (MSs) show great promise in efficient electromagnetic energy harvesting (EMEH) due to their compactness, high efficiency, and long-distance transmission capabilities. Nonetheless, the conventional iterative and time-consuming solving process of MSs significantly escalates computational demands. Furthermore, once processed, the MS shape remains fixed and cannot be adapted to changing requirements. Accordingly, a critical challenge is the development of a new efficient solver for MS real-time tuning. Here, we introduce a class of digital coded MS databases including multiple pre-defined resonant frequency MS. The combination of multiple MS base functions from the database enables swift resonance frequency adjustments to adapt to changing environmental conditions. A topology optimization method based on data-driven modeling is employed to rapidly acquire the optimal digital coding for the corresponding MS at various operating frequencies, facilitating the construction of a database. This approach integrates a convolutional neural network and genetic algorithm (CNNGA). It not only enables more accurate and expedited forward prediction of MSs' electromagnetic (EM) response but also facilitates inverse design based on specified requirements. We employ this method to design a MS that achieves perfect energy harvesting (EH) over a broad range of incident angles and polarization directions. In addition, a data-driven modeling is used to establish an EH efficiency predictive model corresponding to MS combination. This model serves as a guide for real-time MS adjustments as per changing requirements. Compared to previously designed MSs, this model achieves rapid design and adaptive adjustment capabilities. Through the incorporation of various functional MS base functions into the database, this method can be universally applied to MS combinations tailored to specific functions, including EM cloaking, ultra-thin flat lenses, and computational MSs.