When tackling the question, I found that for any $a>1$,
$$ I_1(a)=\int_{0}^{\pi} \frac{d x}{a-\cos x}=\frac{\pi}{\sqrt{a^{2}-1}}. $$ Then I started to think whether there is a formula for the integral
$$ I_n(a)=\int_{0}^{\pi} \frac{d x}{(a-\cos x)^{n}}, $$ where $n\in N.$
After trying some substitution and integration by parts, I still failed and got no idea for reducing the power n. After two days, the Leibniz Rule for high derivatives come to my mind.
Differentiating $I_1(a)$ w.r.t. $a$ by $(n-1)$ times yields
$$ \displaystyle \begin{array}{l} \displaystyle \int_{0}^{\pi} \frac{(-1)^{n-1}(n-1) !}{(a-\cos x)^{n}} d x=\frac{d^{n-1}}{d a^{n-1}}\left(\frac{\pi}{\sqrt{a^{2}-1}}\right) \\ \displaystyle \int_{0}^{\pi} \frac{d x}{(a-\cos x)^{n}}=\frac{(-1)^{n-1} \pi}{(n-1) !} \frac{d^{n-1}}{d a^{n-1}}\left(\frac{1}{\sqrt{a^{2}-1}}\right) \tag{*}\label{star} \end{array} $$
I am glad to see that the integration problem turn to be merely a differentiation problem.
Now I am going to find the $(n-1)^{th} $ derivative by Leibniz Rule.
First of all, differentiating $I_1(a)$ w.r.t. $a$ yields $$ \left(a^{2}-1\right) \frac{d y}{d a}+a y=0 \tag{1}\label{diffeq} $$ Differentiating \eqref{diffeq} w.r.t. $a$ by $(n-1)$ times gets $$ \begin{array}{l} \displaystyle \left(a^{2}-1\right) \frac{d^{n} y}{d a^{n}}+\left(\begin{array}{c} n-1 \\ 1 \end{array}\right)(2 a) \frac{d^{n-1} y}{d a^{n-1}}+2\left(\begin{array}{c} n-1 \\ 2 \end{array}\right) \frac{d^{n-2} y}{d a^{n-2}}+x \frac{d^{n-1} y}{d a^{n-1}}+(n-1) \frac{d^{n-2} y}{d a^{n-2}}=0 \end{array} $$ Simplifying, $$ \left(a^{2}-1\right) y^{(n)}+(2 n-1) ay^{(n-1)}+(n-1)^{2} y^{(n-2)}=0 \tag{2}\label{diffrec} $$
Initially, we have $ \displaystyle y^{(0)}=\frac{1}{\sqrt{a^{2}-1}}$ and $ \displaystyle y^{(1)}=-\frac{a}{\left(a^{2}-1\right)^{\frac{3}{2}}}.$
By \eqref{diffrec}, we get $$ y^{(2)}=\frac{2 a^{2}+1}{\left(a^{2}-1\right)^{\frac{5}{2}}} $$ and $$ \displaystyle y^{(3)}=-\frac{3 a\left(2 a^{2}+3\right)}{\left(a^{2}-1\right)^{\frac{7}{2}}} $$ Plugging into \eqref{star} yields $$ \begin{aligned} \int_{0}^{\pi} \frac{d x}{(a-\cos x)^{3}} &=\frac{\pi}{2} y^{(2)}=\frac{\pi\left(2 a^{2}+1\right)}{2\left(a^{2}-1\right)^{\frac{5}{2}}} \\ \int_{0}^{\pi} \frac{d x}{(a-\cos x)^{4}} &=-\frac{\pi}{6} \cdot \frac{3 a\left(2 a^{2}+3\right)}{\left(a^{2}-1\right)^{\frac{7}{2}}} =-\frac{\pi a\left(2 a^{2}+3\right)}{2\left(a^{2}-1\right)^{\frac{7}{2}}} \end{aligned} $$ Theoretically, we can proceed to find $I_n(a)$ for any $n\in N$ by the recurrence relation in $(2)$ .
By Mathematical Induction, we can further prove that the formula is $$ \int_{0}^{\pi} \frac{d x}{(a-\cos x)^{n}}=\frac{\pi P(a)}{\left(a^{2}-1\right)^{\frac{2 n-1}{2}}} $$ for some polynomial $P(a)$ of degree $n-1$.
Last but not least, how to find the formula for $P(a)$? Would you help me?