It is not illegal if you do it casually and do not make it an obsession. Another very important point is consent. If your friend communicates that they do not approve of it then it becomes stalking which is illegal and punishable.