The two-dimensional (2D) van der Waals ferromagnetic semiconductors, such as CrI3 and Cr2Ge2Te6, and the 2D ferromagnetic metals, such as Fe3GeTe2 and MnSe2, have been obtained in recent experiments and attracted a lot of attentions. The superexchange interaction has been suggested to dominate the magnetic interactions in these 2D magnetic systems. In the usual theoretical studies, the expression of the 2D Heisenberg models were fixed by hand due to experiences. Here, we propose a method to determine the expression of the 2D Heisenberg models by counting the possible superexchange paths with the density functional theory (DFT) and Wannier function calculations. With this method, we obtain a 2D Heisenberg model with six different nearest-neighbor exchange coupling constants for the 2D ferromagnetic metal Cr3Te6, which is very different for the crystal structure of Cr atoms in Cr3Te6. The calculated Curie temperature Tc = 328 K is close to the Tc = 344 K of 2D Cr3Te6 reported in recent experiment. In addition, we predict two stable 2D ferromagnetic semiconductors Cr3O6 and Mn3O6 sharing the same crystal structure of Cr3Te6. The similar Heisenberg models are obtained for 2D Cr3O6 and Mn3O6, where the calculated Tc is 218 K and 208 K, respectively. Our method offers a general approach to determine the expression of Heisenberg models for these 2D magnetic semiconductors and metals, and builds up a solid basis for further studies.