Diabetes mellitus-induced erectile dysfunction (DMED) is one of the most common complications of diabetes mellitus. Leech and centipede granules (LCG) have traditionally been used as blood-activating agents in various ethnomedicinal systems of East Asia, especially in China. It is often used to regulate bodily functions and considered as adjuvant therapy for promoting blood circulation, alleviating blood coagulation, activating meridians, and relieving stasis. This study aimed to identify potential genes and mechanisms of LCG on DMED from the network pharmacological perspective. The active components of LCG were identified by UHPLC-Q-TOF-MS, TCMID, and the BATMAN-TCM databases, and the disease targets of DMED were obtained from the DisGeNET, CooLGeN, GeneCards databases. After identifying DMED targets of LCG, a protein-protein interaction (PPI) network was constructed. Hub genes and significant modules were identified via the MCODE plug-in of Cytoscape software. Then, significant signaling pathways of the modules were identified using the Metascape database. The probable interaction mode of compounds-hub genes is examined using Molecular Operating Environment (MOE) docking software. Besides, we investigated the effects and mechanisms of LCG on improving erectile function in the streptozotocin (STZ)-induced diabetic rats model. Combined UHPLC-Q-TOF-MS analysis with network pharmacology study, 18 active compounds were selected for target prediction. There are 97 common target genes between LCG and DMED. Enrichment of the KEGG pathway mainly involves in the calcium signaling pathway, NF-kappa B signaling pathway, cGMP-PKG signaling pathway, HIF-1 signaling pathway, PI3K-Akt signaling pathway, and mTOR signaling pathway. Nine hub genes were regulated by LCG in DMED, including CXCL8, NOS3, CRH, TH, BDNF, DRD4, ACE, CNR1, and HTR1A. The results of molecular docking analysis showed that the tyrosin, ursolic acid, and L-Histidine has a relatively stable interaction with corresponding hub genes via generating hydrogen bonds, H-π, and π-π interactions. Significantly, the results in docking predicted a higher affinity of vardenafil to the hub genes compared to the tyrosin, ursolic acid, and L-Histidine. Furthermore, LCG increased the testosterone, erection frequency, the ratio of ICP and MAP, SOD, cGMP, cAMP as well as decreased the MDA, and AGEs expression levels. And, LCG ameliorated the histological change of penile tissues in DMED rats. Hence, LCG attenuates oxidative stress, increases NO production; For the mechanism exploration, LCG could significantly upregulate the mRNA and protein expression of CNR1, NOS3, CRH, TH, BDNF, and DRD4, whereas CXCL8, ACE, and HTR1A levels were significantly higher than those in the DMED group. Moreover, LCG activates the NO/cGMP/PKG pathway, PI3K/Akt/nNOS pathway, cAMP/PKA pathway, and inhibits the HIF-1α/mTOR pathway to improve erectile function. Our results suggest that LCG maybe offer a new therapeutic basis for the treatment of DMED via altering the gene expression of involved metabolic pathways. Copyright © 2020 Elsevier B.V. All rights reserved.