The invention provides polyaryletherketone and a method for preparing the polyaryletherketone. The polyaryletherketone is shown in the chemical formula (I). Compared with existing polyaryletherketone, the polyaryletherketone is characterized in that firstly, due to the fact that carbon-carbon bonds and ketone carbonyl bonds are used as connecting bonds in the aromatic nucleuses of the main chain of the polyaryletherketone, the content of oxygen atoms in the structure of the main chain is reduced, due to the fact that ether bonds are not contained, the trans-etherification effect produced when the molecular chains are heated is avoided, and heat resistance of polymer is improved; secondly, due to the fact that the number of the aromatic nucleuses in the main chain is increased, the rigidity of the main chain is improved, the thermal motion of the molecular chains is limited, and the polyaryletherketone has better dimensional stability; thirdly, due to the fact that imidazole monomers are introduced, the ether bonds which are connected to form the main chain are replaced by carbon-nitrogen bonds, the rigidity of the main chain is also improved due to the fact that imidazole rings are introduced, and the heat resistance of the polyaryletherketone is improved.