PY4E - HTTP (Chapter 12 Part 3)

www.py4e.com - Python for Everybody: Exploring Data in Python 3.0
Please visit the web site to access a free textbook, free supporting materials, as well as interactive exercises.

Пікірлер: 39

  • @FixedITyesterday
    @FixedITyesterday6 жыл бұрын

    For anyone else trying to run this code, the following line needs to be changed: From: cmd = 'GET data.pr4e.org/romeo.txt HTTP/1.0 ' To: cmd = 'GET data.pr4e.org/romeo.txt HTTP/1.0 ' Otherwise, you will get an error 400 returned instead of the expected text.

  • @danielpetrusevski1295

    @danielpetrusevski1295

    6 жыл бұрын

    I've used this change but I still get 'error 400'

  • @FixedITyesterday

    @FixedITyesterday

    6 жыл бұрын

    Found the answer after some Googling. Can only assume that the web server needs new lines to be both line_feed( ) and carriage_return( ) characters in the command string instead of just line_feed. The following video in the series also mentions this - which I saw afterwards.

  • @FixedITyesterday

    @FixedITyesterday

    6 жыл бұрын

    Just looked it up, it required as part of the HTTP syntax, see en.wikipedia.org/wiki/Hypertext_Transfer_Protocol under Message format for details.

  • @epistemophile4420

    @epistemophile4420

    3 жыл бұрын

    For those who want to know, " " is the class Unix/Linux style for the new line. " " is the default Windows style for line separator. " " is a classic Mac style for line separator.

  • @phatcat7924

    @phatcat7924

    2 жыл бұрын

    Thanks a lot. It worked

  • @FixedITyesterday
    @FixedITyesterday3 жыл бұрын

    Reminder for people that you need to change the following line: FROM: cmd = 'GET data.pr4e.org/romeo.txt HTTP/1.0 '.encode() TO: cmd = 'GET data.pr4e.org/romeo.txt HTTP/1.0 '.encode() It required as part of the HTTP syntax, see en.wikipedia.org/wiki/Hypertext_Transfer_Protocol under Message format for details. Can only assume that the web server needs new lines to be both line_feed( ) and carriage_return( ) characters in the command string instead of just line_feed.

  • @swaggedout

    @swaggedout

    11 ай бұрын

    Thank you for coming back three years later and commenting it again, was really disappointed when I saw it didn't run. You have a great day!

  • @bobanmilisavljevic7857

    @bobanmilisavljevic7857

    8 ай бұрын

    Thank you!!!! 🥳👍

  • @Vagen_d
    @Vagen_d4 жыл бұрын

    As of the ending of this video I now believe you. Python really is for everybody!

  • @Pavel0793
    @Pavel07937 жыл бұрын

    nice ending :D

  • @heckclare3923
    @heckclare39232 жыл бұрын

    These videos deserves more veiws

  • @pulapanamgama3482
    @pulapanamgama3482 Жыл бұрын

    I wasn't ready for that outro! 😂🤟

  • @tlhogid663

    @tlhogid663

    Жыл бұрын

    Agreed! 😂

  • @kristjanlink007
    @kristjanlink0073 жыл бұрын

    What could be the problem? When I get romeo.txt it splits on the 4th line, so I get back: But soft what light through yonder window breaks It is the east and Juliet is the sun Arise fair sun and kill the envious moon Who is already s ick and pale with grief When I set the buffer size from 512 to 1024 it printed out correctly. Any ideas? EDIT: I figured it out, the buffer gets filled with 512 bytes with the metadata + the file contents up to that point, in a later video I saw the print statement had the end = "" parameter which makes it work with the 512 byte buffer. The way I figured it out was I removed the decode() method from the data variable and then when I ran the code it was clearly visible that the line is split and when I counted the bytes there were about 512. I am glad I figured this out on my own ☺

  • @lukeslujes1838
    @lukeslujes18384 жыл бұрын

    if i wanted to do this on a https website, how would i go about doing that?

  • @brothermalcolm
    @brothermalcolm2 жыл бұрын

    python (socket)

  • @lv8707
    @lv87072 жыл бұрын

    Why do we get the output only as: But soft what light through yonder window breaks It is the east and Juliet is the sun Arise fair sun and kill the envious moon Who is already sick and pale with grief Even increasing the number of characters from 512 to 8000, I still get the same. Why is that so?

  • @milaloup

    @milaloup

    2 жыл бұрын

    That is all of the text in the file. There simple isn't more in it.

  • @julioarruda8182
    @julioarruda81822 жыл бұрын

    Caotic vibe

  • @gunny5040
    @gunny50405 жыл бұрын

    I get "Your browser sent a request that this server could not understand." message and did not get romeo.txt. Should I install telnet kinda things or something?

  • @reneelague

    @reneelague

    5 жыл бұрын

    I'm getting a 400 Bad Request as well. Maybe the file isn't there any more or something??

  • @johnrogers3315

    @johnrogers3315

    5 жыл бұрын

    use cmd = 'GET data.pr4e.org/romeo.txt HTTP/1.0 ' .encode() then; the sockets react at machine speed, if it doesn't receive instruction very quickly it terminates. The code works when the kernel has been refreshed and then all cells are run as 'run all' (or whichever IDE command you use).

  • @CarolinaNT

    @CarolinaNT

    5 жыл бұрын

    @@johnrogers3315 thanks!

  • @babadepou

    @babadepou

    5 жыл бұрын

    @@johnrogers3315 Hey! Thanks for your answer it helped me too! I was wondering what is the function of the you've added to the command. Thanks

  • @pvperez1

    @pvperez1

    5 жыл бұрын

    @@johnrogers3315 Thanks! That worked for me

  • @ghaithdev
    @ghaithdev Жыл бұрын

    For some reason I cannot see the metadata when I do this

  • @ChuckSeverance

    @ChuckSeverance

    Жыл бұрын

    More and more servers do not support the HTTP 1.1 protocol you you can't always reproduce these examples perfectly.

  • @luanvu8717
    @luanvu8717 Жыл бұрын

    Is it me or some hacker checked that texted file and messed up the last sentence with? “Who is already s ick and pale with grief”

  • @tlhogid663

    @tlhogid663

    Жыл бұрын

    No - I think there might be something wrong with your code

  • @hemalshah9085
    @hemalshah90857 жыл бұрын

    lol