High detection frequency of illicit drugs in water samples urges the development of rapid detection method for wastewater-based epidemiology (WBE) study. Here, we first developed a fast, convenient, and cost-effective method by combining thin-film microextraction (TFME) with gas chromatography-mass spectrometry (GC-MS) for sensing illicit drugs in wastewater sample. A divinylbenzene particle-loaded membrane was prepared by dip coating on a copper mesh. The sampling conditions of three illicit drugs were optimized and the performance of the proposed method was evaluated. The limit of detection was 5.5 2.0, and 1.1 ng L-1 for methamphetamine (MAMP), ketamine (KET), and methaqualone (MEQA), respectively, with acceptable precision (< 6.1 % for membrane to membrane reproducibility) and recovery from influent water (95 % - 111 %). Then, the proposed method was applied to study the occurrence and distribution of the target compounds in a wastewater treatment plant. The presence of methamphetamine, ketamine, and methaqualone was confirmed and their concentrations in the influent sample were 57 ± 8, 40 ± 4, and 75 ± 2 ng L-1, respectively. The speciation of the target compounds in different ponds was also investigated. Results showed that the content of organic matter and the pH of the sample significantly affected the binding state of the compounds. This work provides an efficient and accurate analytical protocol for WBE investigation of illicit drugs.