-
-
Save MichelleDalalJian/f89c989e825f092b0ca428c390a6edb1 to your computer and use it in GitHub Desktop.
import socket | |
mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
mysock.connect(('data.pr4e.org', 80)) | |
cmd = 'GET http://data.pr4e.org/intro-short.txt HTTP/1.0\r\n\r\n'.encode() | |
mysock.send(cmd) | |
while True: | |
data = mysock.recv(512) | |
if (len(data) < 1): | |
break | |
print(data.decode()) | |
mysock.close() |
i followed this process but got a traceback in line 1 and line 3
The same here. Have you found what was causing these tracebacks?
Last-Modified:
Sat, 13 May 2017 11:22:22 GMT
ETag:
1d3-54f6609240717
Content-Length:
467
Cache-Control:
max-age=0, no-cache, no-store, must-revalidate
Content-Type:
text/plain
This is working.
Last-Modified:
Sat, 13 May 2017 11:22:22 GMT
ETag:
1d3-54f6609240717
Content-Length:
467
Cache-Control:
max-age=0, no-cache, no-store, must-revalidate
Content-Type:
text/plainThis is working.
![Error](https://user-images.githubusercontent.com/89157542/132367328-d2420673-fed3-4f9a-8366-6e56374accf8.PNG
can you help me?
Server: Apache/2.4.18 (Ubuntu)
Last-Modified: Sat, 13 May 2017 11:22:22 GMT
ETag: "1d3-54f6609240717"
Accept-Ranges: bytes
Content-Length: 467
Cache-Control: max-age=0, no-cache, no-store, must-revalidate
Pragma: no-cache
Expires: Wed, 11 Jan 1984 05:00:00 GMT
Connection: close
Content-Type: text/plain
thank you
wonderful!
what is cache control??
If you run the code in what ever IDE (Pycharm for example) you are using you will see:
Last-Modified: Sat, 13 May 2017 11:22:22 GMT
ETag: "1d3-54f6609240717"
Accept-Ranges: bytes
Content-Length: 467
Cache-Control: max-age=0, no-cache, no-store, must-revalidate
Pragma: no-cache
Expires: Wed, 11 Jan 1984 05:00:00 GMT
Connection: close
Content-Type: text/plain
Why should you learn to write programs?
Writing programs (or programming) is a very creative
and rewarding activity. You can write programs for
many reasons, ranging from making your living to solving
a difficult data analysis problem to having fun to helping
someone else solve a problem. This book assumes that
everyone needs to know how to program, and that once
you know how to program you will figure out what you want
to do with your newfound skills.
Process finished with exit code 0
Ensure you are highlighting the code if you have not saved it otherwise it will exit with a code 0
i am getting this error if i am following these steps and if i am writing 'telnet data.pr4e.org 80' then pasting the URL given in the assignment it is showing:
HTTP/1.1 400 Bad Request
Date: Sat, 31 Oct 2020 18:45:33 GMT
Server: Apache/2.4.18 (Ubuntu)
Content-Length: 308
Connection: close
Content-Type: text/html; charset=iso-8859-1
Connection to host lost.
please help me.