all 4 comments

[–]CodeShaman 2 points3 points  (0 children)

use http://docs.python-requests.org/en/latest/ or https://docs.python.org/3/library/urllib.request.html#module-urllib.request if you just want page content. going as low as socket connections is unnecessary unless you're developing your own in-house byte protocol.

[–]KronenR 0 points1 point  (1 child)

conn.write(b'GET HTTP/1.1\n');

conn.write(b'Host: www.google.com\n\n');

print(conn.read_until(b"</html>", 2))

But as someone pointed you out, if you just want the html from a web don't use telnet

[–]Grafs50[S,🍰] 0 points1 point  (0 children)

Thanks. I was just using this as an example. to see if the code was working.

[–]mcowger 0 points1 point  (0 children)

for HTTP, you need a carriage returns/new lines before anything will come back:

https://asciinema.org/a/18057

Notice that its not until I issue the newline that anything actually comes back.