First note that $$\lim_{x \to \tfrac{\pi}{2}^-} \sin(x) = 1$$ and $$\lim_{x \to \tfrac{\pi}{2}^-} \cos(x) = 0.$$
therefore $$\lim_{x \to \tfrac{\pi}{2}^-} \frac{\sin(x)}{\cos(x)} = + \infty$$ since we have (by the definition of limit):
$$\forall \varepsilon_1, \exists \delta_1, \forall x < \tfrac{\pi}{2}, |x - \tfrac{\pi}{2}| < \delta_1 \to |\sin(x) - 1| < \varepsilon_1$$ and
$$\forall \varepsilon_2, \exists \delta_2, \forall x < \tfrac{\pi}{2}, |x - \tfrac{\pi}{2}| < \delta_2 \to |\cos(x) - 0| < \varepsilon_2$$ which together imply
$$\forall y, \exists \delta_3, \forall x < \tfrac{\pi}{2}, |x - \tfrac{\pi}{2}| < \delta_3 \to \frac{\sin(x)}{\cos(x)} > y$$
by letting $\delta_3 = \delta_2(\tfrac{1}{y})$ here $\delta_2$ is considered as a function of $\varepsilon_2$ by skolemization.
verification: Given $\delta_3 = \delta_2(\tfrac{1}{y})$ we see that $|\cos(x)| < \frac{|\sin(x)|}{y} < \frac{1}{|y|}$ and since both functions $\sin$ and $\cos$ are positive for these values of $x$ we have $\frac{\sin(x)}{\cos(x)} > y.$
You can prove the $-\infty$ part similarly.