title: Python: Extract text from Word files in a url
body: <p>Given the url containing a certain file, in this case a word document, read the contents of the document. I have seen several examples of how to extract text from local documents but not from a url. Would it be the same from an http address than from an ftp?</p>
  
  <pre><code>from urllib.request import urlopen
  
  url = 'ftp://path/to/file.docx'
  
  txt = urlopen(url).read()
  </code></pre>
  
  <p>the value of text is:</p>
  
  <pre><code>b'PK\x03\x04\x14\x00\x06\x00\x08\x00\x00\x00!\x00\xdd\xfc\x957f\x01\x00\x00 \x05\x00\x00\x13\x00\x08\x02[Content_Types].xml \xa2\x04\x02(\xa0\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 ...'
  </code></pre>
  
  <p>I try to decode </p>
  
  <pre><code>txt.decode("utf-8", "ignore")
  </code></pre>
  
  <p>but this returns <code>PK ...</code> followed by other strange characters</p>
  
  <p>The option to save the document and then process it is not feasible.</p>
  
  <p>What am I doing wrong?</p>