For ocean oil wells, build an underwater shaft around the central well, or else the pump will pump the entire ocean dry before advancing down deeper.
For filterig liquid in pipes, have the same pipe connect to two tanks. In one tank, put some water, in the other tank, put some oil. Since a tank can only hold one type of liquid, the contents of the pipe will "sort" themselves into the proper tank, and you can then pump pure liquid out of that tank. Be careful though to never completely empty either tank.