Designing optimal structure favorable to diffusion and effectively controlling the trapping process are crucial in the study of trapping problem-random walks with a single trap. In this paper, we study the trapping problem occurring on unweighted and weighted networks, respectively. The networks under consideration display the striking scale-free, small-world, and modular properties, as observed in diverse real-world systems. For binary networks, we concentrate on three cases of trapping problems with the trap located at a peripheral node, a neighbor of the root with the least connectivity, and a farthest node, respectively. For weighted networks with edge weights controlled by a parameter, we also study three trapping problems, in which the trap is placed separately at the root, a neighbor of the root with the least degree, and a farthest node. For all the trapping problems, we obtain the analytical formulas for the average trapping time (ATT) measuring the efficiency of the trapping process, as well as the leading scaling of ATT. We show that for all the trapping problems in the binary networks with a trap located at different nodes, the dominating scalings of ATT reach the possible minimum scalings, implying that the networks have optimal structure that is advantageous to efficient trapping. Furthermore, we show that for trapping in the weighted networks, the ATT is controlled by the weight parameter, through modifying which, the ATT can behave superlinealy, linearly, sublinearly, or logarithmically with the system size. This work could help improving the design of systems with efficient trapping process and offers new insight into control of trapping in complex systems.