Understanding the network structure is critical for controlling and mitigating the spread of infectious diseases. Removing many important links to control the spread of infectious diseases is often more convenient and cost-saving than isolating individuals. Therefore, we develop an algorithm (RW) for identifying important links based on random walks in complex networks. With the guarantee of network connectivity, removing many important links from the network can better reduce the largest eigenvalue of the adjacency matrix, thus increasing the epidemic threshold and reducing the fraction of infected individuals, and further effectively controlling the spread of infectious diseases. In order to verify the effectiveness and scalability of our algorithm, we conducted many experiments on top of a large number of real-world networks and synthesis networks to compare with some classical algorithms. The results show that our algorithm can effectively identify important links to control the spread of infectious diseases in social networks.