ENOfficial
It was narrated from Ibn Abbas that the Messenger of Allah(ﷺ) said: "Whoever learns about the stars, he learns a branch of magic; the more he learns (of the former) the more he learns (of the latter)."
Source: sunnah.com
Other translations
Arabic
حَدَّثَنَا أَبُو بَكْرٍ، حَدَّثَنَا يَحْيَى بْنُ سَعِيدٍ، عَنْ عُبَيْدِ اللَّهِ بْنِ الأَخْنَسِ، عَنِ الْوَلِيدِ بْنِ عَبْدِ اللَّهِ، عَنْ يُوسُفَ بْنِ مَاهَكَ، عَنِ ابْنِ عَبَّاسٍ، قَالَ قَالَ رَسُولُ اللَّهِ ـ صلى الله عليه وسلم ـ " مَنِ اقْتَبَسَ عِلْمًا مِنَ النُّجُومِ اقْتَبَسَ شُعْبَةً مِنَ السِّحْرِ زَادَ مَا زَادَ " .
sunnah.com