It's also possible to pull a lot of data out of the game's own data files, which I'm sure Wowhead and the like do.
If you're talking about sites that show player profile info, they're pulling it from the official Battle.net API:
https://dev.battle.net/
However, neither of those will provide you with any way to export arbitrary data from in-game in real-time. That's simply not allowed, by design.