samedi 7 février 2015

Why does my python socket get 404 error?


socket = socket(AF_INET, SOCK_STREAM)
socket.connect(("www.youtube.com", 80))
file = socket.makefile('r', 0)
file.write("GET " + "watch?v=MsFohjWLKdI" + " HTTP/1.0\n\nHost: " + urlParsed.netloc + "\n\nConnection: close\n\n")
buff = file.readlines()


buff (server response) says 404 file not found. But in my Chrome I see the page. When I send GET request to youtube index page (http://www.youtube.com) buff doesn't get error. This happens to other websites too: I can only get response from index page.


What's wrong with my socket?





Aucun commentaire:

Enregistrer un commentaire