Created
August 15, 2016 14:42
-
-
Save manichabba/a074faa96d9fcc01a6921f9e45a7ccbe to your computer and use it in GitHub Desktop.
Using sockets to read a URL and get information
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
mysock.connect(('www.pythonlearn.com', 80)) | |
mysock.send('GET http://www.pythonlearn.com/code/intro-short.txt HTTP/1.0\n\n') | |
while True: | |
data = mysock.recv(512) | |
if ( len(data) < 1 ) : | |
break | |
print data; | |
mysock.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment