They generally do not look at the data at all, they simply repeat it to all of the other ports. Below is a picture of a rack of hubs at the University. The second picture shows the wiring that is used to connect the hub ports to the various offices. They are able to make slightly more intelligent decisions as to where to forward packets, rather than just repeating them to all ports as hubs do. Below is a picture of a switch installed at the University.
Routers operate at the network layer.
This allows them to make even better decisions regarding what to do with a given packet. Below is a picture of the Computing Center router. All of the cables attached to the router are the building feeds referred to in the previous diagram of the UB backbone. Below is a diagram of the layers used when a packet must traverse a router when traveling between two end stations. Now, with all of the pieces above, you should be able to make a pretty good guess regarding the path of any given packet.