Performing carbon dioxide (CO2) capture in an environmentally benign and cost-effective way is challenging owing to several factors including selectivity. Thus, the development of polymers that provide high capacity and selectivity for the removal of CO2 gas is important. N-based porous polymers are promising for CO2 capture due to their abundant porosity, variable surface characteristics, and great stability. Herein, porous organic polymers were synthesized by microwave-assisted Freidel-Crafts alkylation of 2,2′-bipyridine and pyrrole with dimethoxymethane as a cross-linker. The synthesized polymers were characterized by Fourier transform infrared, nuclear magnetic resonance, thermogravimetric analyzers, and surface analyzers based on Brunauer–Emmett–Teller theory (BET). The porous polymers exhibited high surface areas of 580 – 930 m2/g. The polymers showed high ideal adsorbed solution theory (IAST) selectivity of 53 – 63 toward CO2 over N2 at 1 bar and 298 K under flue gas composition. Whereas the selectivity toward CO2 over CH4 at 1 bar and 298 K under natural gas composition was 12 – 18. The synthesized polymers achieved exceptional H2O adsorption capacity at P/P0 = 0.9 and 293 K of 35 – 45 mmol/g. The results reveal the polymers provide promising candidates for the CO2 capture from various mixtures, such as flue gas and natural gas.