Next time you lose connection, try pinging in increasing circles of the network.
1) Ping another machine on the network that won't reject it because of a firewall (or just ping your router if there are no such available destinations).
2) Assuming that replies, ping an IP available on the Internet. A DNS server is preferable. I'd test with 151.164.70.201.
3) Assuming that replies, ping a textual address, such as google.com.
If step three completes, there's nothing wrong with your connection.
If step three doesn't complete but step two does, you have a DNS problem and need to put in a different server (the one I suggested you ping to test with would be a good choice until they shut it down later this year--never seems to be down).
If steps three and two won't complete but step one does, you've got a problem with your Internet connection (or less likely, your computer).
If none of the steps complete, you've got a problem with your basic network--meaning your WiFi and/or your wired network, including your cable modem.