The first thing that the seeker of knowledge must do is to choose trustworthy scholars, people who are religiously-committed, trustworthy and pious. He should only acquire knowledge from those who are qualified, and those who are truly qualified are those who have the knowledge and act upon it, by obeying Allah and adhering to His laws and commands. The teacher has the greatest effect on the student, so he should have the quality of fear of Allah (taqwa).
"It was narrated that Ibrahim al-Nakha’i said: When they came to a man to acquire knowledge from him, they would look at his character, his prayer and his situation, then they would take knowledge from him." (al-Jaami’ li Akhlaq al-Raawi, 1/127)
Imam Nawawi said: "It should not be learned except from one who is fully qualified and whose religious commitment is apparent, whose knowledge is proven to be sound and whose piety is well known. Muhammad ibn Sirin, Malik ibn Anas and others among the salaf said: This knowledge has to do with religion, so look to whom you take your religion from." (al-Tibyan fi Adaab Hamalat al-Qur’an, 13)
al-Zarnuji said: "He should choose the most knowledgeable, the most pious and the oldest, as Abu Hanifah chose Hammaad ibn Abi Sulayman after much thinking and consideration, and he said: I found him to be a patient, forbearing and dignified old man." (Ta’lim al-Muta’allim, 7)
Ibn Jamaa’ah al-Kinaani said: "The seeker of knowledge should look and pray istikhaarah, asking Allah for guidance concerning the one from whom he will take knowledge and learn good attitude and manners; if possible he should be one who is fully qualified, and is proven to be kind, compassionate and chivalrous, and who is well known for his chastity and piety, and who is well versed and has deep understanding. The student should not continue to learn when there is a shortcoming in (the teacher’s) piety or religious commitment, or his attitude is not good. It was narrated from one of the salaf: This knowledge has to do with religion, so look to whom you take your religion from. If you explore the lives of the earlier and later generations, you will find that the student usually only benefits and succeeds if the Shaykh is clearly sincere towards his students. Even if you look at books, you will find that you will benefit from books authored by those who are more pious and have less interest in worldly gains."
(Tadhkirah al-Saami wa’l-Mutakallim, 133)