A flytrap includes at least a collection barrel, a main unit having an upper seat, a lower seat, an electrode net, a safety net and a guiding plate, a fixing element which is deployed in the electrode net to install a bait, as well as a circuit module. By the abovementioned structural design, the bait is installed in the fixing element and an odor of the bait is used to attract files to approach the electrode net. Next, the flies are shocked electrically with a high voltage on the electrode net and finally, the dead or paralyzed flies are gathered in the collection barrel.