The precise control of scaffold elements and topologies of nanoporous materials shows great prospects in the application of adsorption and separation. In this work, two kinds of porous polymers, silsesquioxane-based porous polymers (PCSs) and triazine-based covalent–organic polymers (covalent triazine-based frameworks, CTFs), were prepared by the Heck reaction and Suzuki reaction of triazine monomers with octavinylsilsesquioxane and p-phenylboronic acid, respectively. A series of experimental results showed that the specific surface areas (SBET) and the morphological structures of the target materials can be controlled by regulating the building modules. The PCSs are irregular nanoporous aggregates with SBET values of 360∼560 m2 g–1, while the CTFs are regular hollow tubular polymers with SBET values of about 30∼70 m2 g–1. Different SBET values result in different adsorption capabilities of iodine in the volatile or solution phase. For volatile iodine, the adsorption capacity of CTFs is up to 2.5 g g–1, larger than that of PCSs, while in iodine–cyclohexane solution, the adsorption capacity of PCSs is larger than that of CTFs. Due to the fluorescence quenching caused by charge transfer between the polymers and I2, two polymers can be used to detect I2 with good selectivity and sensitivity. In this work, the porosity, fluorescence properties, and adsorption capacity of the target materials were successfully regulated by adjusting the scaffold units and topological structures of starting materials, thus realizing the sensitive detection and efficient adsorption of iodine.