I'd like to create a method that returns the HTML for a url that's passed as a parameter. I'm aware of how to do this using tools like "urllib2" or "requests". However, I am restricted to using sockets. So far i've tried this and it's not working.
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((url, 80))
s.sendall("GET / HTTP/1.0\r\n\r\n")
return s.recv(4096)
The error is with the request, I think it's formatted incorrectly.
I've tried some similar solutions from other users here, but none of them have worked. Any help would be appreciated, thanks.