The invention discloses a code searching method based on semantics. A system adopted in the method mainly comprises a data collection module, a data analysis module, a data sorting module and a user interaction module, wherein a crawler tool JoBo in the data collection module can preset certain website addresses in a configuration file, a code source is fetched from a preset forum and blog to most effectively fetch the webpage at the highest speed; the code source fetched by the crawler tool JoBo is subjected to semantic analysis by an abstract syntax tree AST frame in an open-source tool JDT (Java Development Tools ); the data sorting module is matched according to keywords input by a user; and after a corresponding search result is obtained by analysis, factors on five aspects are comprehensively considered, and the search results are successively sorted and displayed to the user from the higher score to the lower score by sorting data. On the basis of utilizing the traditional best search engine, the code searching method correspondingly expands semantic information identification and sorting, defines a search range by configuring a crawler, improves the search efficiency and the precision accuracy, and considers user favor.