It is quite possible to determine all polynomials that satisfy the given integral equation. Let $p_n(x)= a_0+a_1 x+\cdots a_n x^n = \sum_{k=0}^n a_k x^k$. Substituting in we get
$$\int_1^2 \left(\sum_{k=0}^n a_k x^{2k} \right)^2 dx+5 \int_2^3 \sum_{k=0}^n a_k x^{2k}dx+7\int_3^4 \sum_{k=0}^n a_k x^k dx=\frac{1871}{30}.$$
Now it is a matter of choosing your $n$, expanding, integrating and explicitly writing down the equation. For $n=0$ we get (as mentioned in my comment)
$$a_0^2+12a_0=1871/30.$$
For $n=1$ we first get
$$\int_1^2 (a_0^2+2a_0a_1x^2+a_1^2x^4) dx + 5\int_2^3 (a_0 + a_1 x^2) dx+7 \int_3^4 (a_0+a_1x)dx = \frac{1871}{30},$$
or after integrating and collecting terms,
$$a_0^2 + 2a_0a_1 (8-1)/3+a_1^2 (32-1)/5+5a_0+5a_1(27-8)/3+7a_0+7a_1(16-9)/2 = 1871/30$$
or
$$a_0^2+a_0a_1 \frac{14}{3}+a_1^2 \frac{31}{5}+12 a_0 + \left(\frac{19\cdot 5}{3} + \frac{49}{2} \right) a_1 = \frac{1871}{30}.$$
Setting $a_0=0$ we verify that
$$\frac{31}{5}+\frac{19\cdot 5}{3} + \frac{49}{2} = \frac{1871}{30}$$
so that $f(x)=x$ is a solution.
But if you look closely you'll see there is another $f(x)=cx$ satisfying the equation.
Let's go to Taylor series and assume that $f(x) = \sum_{k=0}^n a_k x^k$ is analytic with radius of convergence $R>9$.
Then computing
$$\int_1^2 \left(\sum_{k=0}^\infty a_k x^{2k} \right)^2 dx+5 \int_2^3 \sum_{k=0}^\infty a_k x^{2k}dx+7\int_3^4 \sum_{k=0}^\infty a_k x^k dx=\frac{1871}{30}$$
and using the Cauchy product,
$$ \sum_{k=0}^\infty \left[ \int_1^2 \sum_{j=0}^k a_j a_{k-j} x^{2k} dx+5 \int_2^3 a_k x^{2k}dx+7\int_3^4 a_k x^k dx \right]=\frac{1871}{30}$$
and rearranging and integrating finally gives
$$ \sum_{k=0}^\infty \left[ \sum_{j=0}^k a_j a_{k-j} \frac{2^{2k+1}-1}{2k+1} + a_k \left(5 \cdot \frac{3^{2k+1}-2^{2k+1}}{2k+1} + 7 \cdot \frac{4^{k+1}-3^{k+1}}{k+1}\right)\right]=\frac{1871}{30}.$$
We see from this that if a sequence $a_n$ satisfies the above constraint and if $a_k \geq 0$ for all $k$, then $a_k$ must diminish at least exponentially faster than $1/9^k$. So in this case satisfying the constraint implies that the function is analytic with radius of convergence greater than or equal to 9. Staring at the expression, you should eventually convince yourself that this is true regardless of the sign of $a_n$ (use the condition that difference of partial sums go to zero).
Because of this required decay, you might even be able to show, by picking the first $n$ coefficients, that for any analytic function $g$ there is another function $f$ as close as you like to $g$ (in the supremum norm) such that $f$ satisfies the constraint. This might be a hogwash, though, but, achille hui's comment does also give a suggestion of something of this sort. Note that his answer does not assume continuity or smoothness of $f$. However, I'll leave proving or disproving that to another day.