Energy harvesting (EH) technology is considered to be a promising approach to provide enough energy for energy-constrained Internet of Things (IoT). In this paper, we propose an energy harvesting and information transmission mode for the spectrum sharing system with cooperative EH-abled IoT applications in beyond 5G networks. Different from most existing IoT spectrum-sharing research studies, in our system, both primary user (PU) and IoT devices (IDs) collect energy for their information transmission. In addition, for all IDs, they should realize two communication functions: working as relays to help the information transfer process of PU and completing their own information transmission. We analytically derive exact expressions for the throughput of the primary system and IoT system and then formulate two objective functions. It is easy to see that power splitting ratio, dynamic EH ratio, power sharing ratio, and relay selection should be optimized to get the best performance for different communication circumstances. Actually, it is a hybrid NP-hard problem to optimize these parameters and traditional algorithms cannot solve it well. Therefore, a novel algorithm-quantum whale optimization algorithm (QWOA) is proposed to obtain the best performance. Simulation results show the good performance of QWOA in different simulation scenarios.