I know how to instantiate web3 to work with a local test network:
var web3Instance = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
How do I change this code to connect to the real network?
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the decentralized application platform and smart contract enabled blockchain. It only takes a minute to sign up.Sign up to join this community
That is how you connect to a real network, with web3.
The difference, however, is that instead of connecting to a testrpc (or Parity or Geth) node running a local, private network exposing an RPC interface, that instead you connect to a client connected to one of the test networks (or mainnet).
In the case of using HttpProvider, just start your client with the necessary JSON RPC interfaces exposed.
The documentation on the Ethereum wiki gives you examples for a number of different clients.