The Messenger of Allah ﷺ said, "Whoever acquires a branch of knowledge from astrology has acquired a branch of magic. The more he learns of it, the more magic he has gained."
حدثنا أبو بكر حدثنا يحيى بن سعيد عن عبيد الله بن الأخنس عن الوليد بن عبد الله عن يوسف بن ماهك
قال رسول الله ﷺ من اقتبس علما من النجوم اقتبس شعبة من السحر زاد ما زاد
[Its chain of transmission is hasan] Abu Dawud narrated it in the Book of Medicine, Chapter on the Stars, no. 3905, from Abu Bakr bin Shayba, with this wording, and it is found in al-Musannaf, 8/414. Nawawi and Dhahabi graded it sahih, while Munziri indicated that it is hasan.