1

Trying to download a file directly using Python and the Google Drive API exportlinks response.

  1. Suppose I have an export link like this:

    a) https://docs.google.com/feeds/download/documents/export/Export?id=xxxx&exportFormat=docx

  2. To download this file, I simply paste it into the browser, and the file automatically downloads to my Downloads folder.

  3. How do I do the same thing in Python?

    EX: module.download_file_using_url(https://docs.google.com/feeds/download/documents/export/Export?id=xxxx&exportFormat=docx)

Community
  • 1
  • 1
Christopher Carlson
  • 963
  • 2
  • 10
  • 20
  • Possible duplicate of [How do I download a file over HTTP using Python?](http://stackoverflow.com/questions/22676/how-do-i-download-a-file-over-http-using-python) – Bailey Parker Jan 12 '16 at 09:15

1 Answers1

0

This is a repost of How do I download a file over HTTP using Python?

In Python 2, use urllib2 which comes with the standard library.

import urllib2 response = urllib2.urlopen('http://www.example.com/') html = response.read()

This is the most basic way to use the library, minus any error handling. You can also do more complex stuff such as changing headers. The documentation can be found here.

Community
  • 1
  • 1
dimitrieh
  • 401
  • 3
  • 17