I'll answer for gen 3 and gen 4 because those are the games I played.
You'll want a fast false swiper and a fast Pokemon with both a trapping move (block, mean look, or spider web) and a sleep move, and lots of healing items (including but not limited to leftovers), Leppa berries, and timer balls. You can find Pokemon that learn certain move combinations in certain generations by using the /ds3 or /ds4 command on Pokemon Showdown!. Save your game each time the roaming Pokemon appears in your location. Put the false swiper first in your party, keep encountering the Pokemon and using powerful attacks until it faints, soft reset, and use false swipe to bring it down to 1 HP. Next time you encounter the Pokemon, trap it and put it to sleep every time it wakes up. Timer balls achieve their maximum catch rate after 30 turns, so keeping the Pokemon asleep before you start using timer balls will decrease the chance of running out of PP.
In gen 3, roaming Pokemon often move away from you when you move from one outdoor location to another, but they seem to move randomly when you exit a building. If a roaming Pokemon ends a battle by using roar, it will permanently stop roaming, so you should soft reset immediately. In gen 4, you can find roaming Pokemon by moving back and forth between any 2 outdoor areas that have either tall grass or water are not cities (like Route 205 and Valley Windworks).
source