If theres a reasonable marking - I google that. If not, I narrow it down by context and then package, and finally pinout. For example, if its an 8 pin SOIC, with pins 5-8 joined, and 1-3, its most likely a MOSFET. Fat traces usually mean power. SOT23 usually have just two characters, and goolging that bings up loads of results, but you can tell by the circuit its in whether its PNP/P channel, or NPN, or even single/dual diodes.
Sometimes it doesn't really matter - if a circuit has a 3 pin device driving a MOSFET that enables power to something, it doesn't always matter what the exact part number of the transistor is, just that its switching.
These days there are an increasing number of "black" devices that dont' really have an online footprint - switching regulators for LED lighting, odd micros etc.. can be annoying but often these are in pretty cheap devices that just aren't worth repairing. Stuff that we usually think are worth repairing are either vintage stuff = which greatly increases the likelihood of finding datasheets, or expensive high end gear, where the designers haven't had to race to the bottom, so use what they are comfortable usuing and what works best in circuit. Either way, tends to be pretty straightforward to find data on most devices.