-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Motivation/Problem Statement πβ:
I'm keeping my eye on my short-term Python goal: Earn the Python for Everyone specialization on Coursera.
Today's Goal/Solution π₯ :
Work on Week 3 of Using Python to Access Web Data.
Result πππ:
I finished the Week 3 assignments (quiz and exercise). It was really cool. I actually sent an HTTP request using the socket module to connect to port 80 of the specified web server, and then received the data and printed it.
My Code:
import socket
my_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
my_socket.connect(('data.pr4e.org', 80))
cmd = 'GET http://data.pr4e.org/intro-short.txt HTTP/1.0\r\n\r\n'.encode()
my_socket.send(cmd)
while True:
data = my_socket.recv(512)
if len(data) < 1:
break
print(data.decode(),end='')
Screeenshot from Terminal:
Isn't that dope? I'm really excited about this course. And I'm looking forward to the other things we'll get to do. And I'm sure all that time I spent on HTML and CSS will come in handy.
Observations & Next Steps ππ£:
Reading the chapter on networked programs helped me a lot. I first I was really uncomfortable with the content, but. I managed to understand a lot more after reading. I still feel like I need to go over the lecture videos from Week 3 one more time in order to really solidify the content, but overall I'm happy with what I was able to do.
References π:
Link any useful resources you may have found throughout the day.
Extra/Fun (Optional) πππ₯³:
None
