Skip to content

Completed Week 3 of Python course 3 (05/26)Β #65

@anitabe404

Description

@anitabe404

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:

Screen Shot 2021-05-27 at 12 55 39 AM

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions