I start out trying to imitate the basslines of new songs in my repertoire but at a point where I am confident of the song structure I sometimes improvise.
Occasionally I will download YT clips of different versions of the same song and imitate the cover bassist as well as the original. E.g. I Shot the Sheriff by Bob and the Wailers or by Eric C. Another example being Chic's Good Times with either BE or with JB. Eventually you end up with a variety of note choices to pull out of your hat.
Getting accurate TAB is rare so it's good to try a few different TABbed opinions of what the bass is doing by saving them from the various free sources online if you aren't hearing it well enough on a recording. Ideally, it's good to write your own musical notes. With a bit of practice it can help a lot because you really take a song to pieces and rebuild it in the process.
If you're seriously trying to reproduce an original sound, say, for a tribute band, I would recommend paying for an official score. Be aware though that published music is not always the definitive version. Studio recordings and live performances by the same band can have very different basslines or even bassists!
Trust your ears above all else.