Due to the popularity of crowdsourcing, more crowds are participating in crowdsourcing tasks. However, the proportion of spam workers is continuously increasing due to the openness of crowdsourcing platforms and their incentive mechanisms. To defend against threats from spam workers, researchers have proposed reputation-based and verification-based detection methods, but they either cannot address various collusion patterns or are costly when facing a large number of spam workers with "good" reputations due to collusion. Therefore, we propose a spam worker detection approach based on heterogeneous network embedding. We first model three collusion patterns and analyze the characteristics of spam workers to provide a theoretical basis for detecting spam workers. We then transform the problem of spam worker detection into a node classification problem in a crowdsourcing heterogeneous network in which the vectors of worker nodes are learned using network embedding. To improve the efficiency of network embedding, we propose an improved variable-length random walk algorithm based on node centrality. Finally, based on the obtained vectors of worker nodes, a one-class SVM is used to detect spam workers. The experiments demonstrate that our proposed approach can effectively detect spam workers in different collusion patterns and that the proposed random walk algorithm can reduce the time spent on model training while improving the efficiency of network embedding.