I found a post with a pic of the same thing I found and the OP was told it was boar glue. Both my daughter's guinea pigs are female so I was curious if it could be something else
It's a mucus plug. When a guinea pig goes out of heat (about every 14-16 days), the entrance to her uterus is blocked by a mucus plug. She loses it when she comes into heat again.