It won't work for two reasons:
The issue is not the modem speed, but the speed of the network that carries traffic to the modem.
If you try to measure downstream from the modem, you'll have to add in other traffic sources. For example, if you're downloading at 5Mbps and the speed tests gives 6Mbps, that is the ISP delivering more than 10Mbps, not less. So you cannot automate it. Someone must know what else is going on at the time.
The provider knows whether their pipes are congested and, if so, when and how much. If they're lying to you about the problem, then that's an issue that goes way beyond proving to them that they are lying.