Bactrocera dorsalis (Hendel) (B. dorsalis) is an important agricultural invasive pest that causes significant economic losses in tropical and subtropical fruit and vegetable crops. In this study, the proteins related to the sense of smell and taste of B. dorsalis, such as OBP, PBP, OR, IR, SNMP and CSP, were screened based on B. dorsalis transcriptome data. By integrating the compounds that were reported to be attractive to B. dorsalis, similar compounds of hydrocarbon compounds were obtained. Molecular docking was used to predict the binding between the similar compounds and the OBP, PBP, OR, IR, SNMP and CSP proteins. Network pharmacology was used to screen the potentially attractive compounds, and ecological experiments with B. dorsalis were finally conducted to verify the effect of these potentially attractive compounds on B. dorsalis. The results showed that the G protein-coupled receptor [BR: KO04030] and ion channel [BR: KO04040] pathways were closely related to the odor tropism of B. dorsalis. A total of 84 compounds, such as mitemcinal, exemestane and midecamycin, have potential binding effects on the B. dorsalis odor receptor proteins. The results of the ecological experiments showed that 1 mg/mL and 0.1 mg/mL 19-norandrostenedione, 1 mg/mL progesterone compounds was significantly attractive to B. dorsalis males, while 0.1 mg/mL exemestane was significantly attractive to B. dorsalis females. In this study, network pharmacology technology was used to discover the potential attractive compounds for B. dorsalis, which is important for the development and subsequent prevention and control of B. dorsalis. It can provide a reference in improving the success rates of clinical trials of new pest control products and in reducing the time and cost of drug development.