newbie problem: use socke lib to retrieve one web page:

koko kokohh at hotmail.com
Wed Sep 4 23:53:44 EDT 2002


I write this to retrieve one web page using socket lib.

# retrieve webpage
import socket
HOST='www.uic.edu' # remote host
PORT=80     # remort port
s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
m="""GET /home/events.shtml HTTP/1.0
From: hh at uic.edu
User-Agent: test/1.0
"""
s.connect((HOST,PORT))
s.send(m)
data=s.recv(4096)
print data
s.close()

-----------
But I retrieved nothing and the program stuck.





More information about the Python-list mailing list