Inside most laptops, there is a WiFi Antenna. I once also had an issue with my laptop allowing me access, and then flicking off again. So every time I tried to use a program called "Steam" I would be disconnected from the servers. Inside the laptop, there is a wire that is attached to the WiFi receiver, that gets plugged into your laptops motherboard, If it is loose, just disconnect it completely, then plug it back in. If the antenna is warm, or hot. That means it is burnt out, and will continue not to work unless it is properly cooled. You CANNOT cool a WiFi antenna, so it is best to either search the web, and buy a new WiFi antenna that is the same model and brand as the one in your laptop, or just buy a LAN/Ethernet cable and play like that.
*NOTE - When you first buy a Ethernet cable, the laptop WiFi antenna must be removed, otherwise the laptop will switch between the two, and will make you periodically loose internet connection. Also, the computer will still (not as much) continue to disconnect, and reconnect for a while. Roughly 8-10 days, and then everything should smooth-en out. Here is a link to an image of a WiFi antenna for laptop:
Or, yours may look something like this:
Hopefully this helps you!