Desperately trying to find an answer or alibi. The phrase might create the image of hanging from a cliff and before falling to death, grabbing after straws (hay weeds etc.) to save oneself, an apt representation of the meaning. Often used in response to someone who keeps tossing out many excuses for a mistake. (Compare to Last ditch effort.)
“He needs to pay off a big debt so he’s looking for gold in the local river,I think he’s just grasping at straws.