billwala wrote a reply+100 XP
1d ago
Adding to what's been said above—the scraping-vs-official-access distinction really matters here, both legally and practically.
Most Pakistani DISCOs (LESCO, MEPCO, FESCO, etc.) don't publish a public API, but several of them expose a lightweight bill-lookup endpoint that's intended for online bill retrieval. That's very different from logging into a customer portal and scraping authenticated content.
The safer approach is to:
- Don't ask users for their utility account credentials. A reference number or customer ID printed on the bill is usually sufficient.
- Either embed the official bill-check page where appropriate or interact with the same lightweight endpoint used by the official bill-check interface, rather than scraping authenticated pages.
- Cache responses sensibly since bills typically update once per billing cycle.
- Avoid storing bill data or reference numbers longer than necessary to complete the request.
If you're building this in Laravel, using the Http:: client (Guzzle-based), validating reference numbers with Form Requests for each DISCO, and adding a queue plus cache layer can make the application more reliable and scalable.
I implemented a similar solution while building BillWala.pk, a Pakistan utility information platform that provides guides for checking duplicate electricity and gas bills across multiple DISCOs. For long-term reliability and easier maintenance, I chose the iframe/lightweight-endpoint approach instead of scraping authenticated customer portals, largely because of the concerns around terms of service, site changes, and system stability.