Maternal infection during pregnancy is an important cause of autism spectrum disorder (ASD) in offspring, and inflammatory infiltration caused by maternal immune activation (MIA) can cause neurodevelopmental disorders in the fetus. Medicine food homologous (MFH) refers to a traditional Chinese medicine (TCM) concept, which effectively combines food functions and medicinal effects. However, no previous study has screened, predicted, and validated the potential targets of MFH herbs for treating ASD. Therefore, in this study, we used comprehensive bioinformatics methods to screen and analyze MFH herbs and drug targets on a large scale, and identified resveratrol and Thoc5 as the best small molecular ingredient and drug target, respectively, for the treatment of MIA-induced ASD. Additionally, the results of in vitro experiments revealed that resveratrol increased the expression of Thoc5 and effectively inhibited lipopolysaccharide-induced inflammatory factor production by BV2 cells. Moreover, in vivo, resveratrol increased the expression of Thoc5 and effectively inhibited placental and fetal brain inflammation in MIA pregnancy mice, and improved ASD-like behaviors in offspring.