title: I am having some trouble in this python exercise
body: <p>I have a problem with this exercise, here is the exercise:</p>
  
  <p>Change your socket program so that it counts the number
  of characters, it has received and stops displaying any text after it has shown 3000 characters. The program should retrieve the entire document and count the total number of characters and display the count
  of the number of characters at the end of the document.</p>
  
  <p>Original Code:</p>
  
  <pre><code>import socket
  mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  mysock.connect(('data.pr4e.org', 80))
  cmd = 'GET http://data.pr4e.org/romeo.txt HTTP/1.0\r\n\r\n'.encode()
  mysock.send(cmd)
  while True:
  data = mysock.recv(512)
  if len(data) &lt; 1:
  break
  print(data.decode(),end='')
  mysock.close()
  </code></pre>
  
  <p>MY CODE:</p>
  
  <pre><code>import socket
  url=input("Enter a URL :\n")
  count=0
  host_name=url.split("/")[2]
  mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  try:
      mysock.connect((host_name, 80))
      cmd=('GET url HTTP/1.0\n\n'.encode())
      mysock.send(cmd)
  except:
      print("Enter a valid URl")
  exit()
  
  
  while True:
      data = mysock.recv(512)
      count=count+len(data)
      if len(data) &lt; 1:
          break
      print(data.decode())
  mysock.close()
  </code></pre>
  
  <p>My output:</p>
  
  <pre><code>Enter a URL :
  http://www.py4inf.com/code/romeo.txt
  HTTP/1.1 400 Bad Request
  Server: nginx
  Date: Mon, 06 May 2019 10:29:37 GMT
  Content-Type: text/html
  Content-Length: 166
  Connection: close
  
  &lt;html&gt;
  &lt;head&gt;&lt;title&gt;400 Bad Request&lt;/title&gt;&lt;/head&gt;
  &lt;body bgcolor="white"&gt;
  &lt;center&gt;&lt;h1&gt;400 Bad Request&lt;/h1&gt;&lt;/center&gt;
  &lt;hr&gt;&lt;center&gt;nginx&lt;/center&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I am getting an error Message " 400 Bad request"</p>
  
  <p>Can anyone help me, Thank you</p>