Skip to main content
The 2024 Developer Survey results are live! See the results
urllib.request.urlretrieve is documented as a legacy interface
Source Link
bmaupin
  • 15.6k
  • 6
  • 94
  • 99

Python 3

  • urllib.request.urlopen

      import urllib.request
      response = urllib.request.urlopen('http://www.example.com/')
      html = response.read()
    
  • urllib.request.urlretrieve

      import urllib.request
      urllib.request.urlretrieve('http://www.example.com/songs/mp3.mp3', 'mp3.mp3')
    

    Note: According to the documentation, urllib.request.urlretrieve is a "legacy interface" and "might become deprecated in the future" (thanks gerrit)

Python 2

  • urllib2.urlopen (thanks Corey)

      import urllib2
      response = urllib2.urlopen('http://www.example.com/')
      html = response.read()
    
  • urllib.urlretrieve (thanks PabloG)

      import urllib
      urllib.urlretrieve('http://www.example.com/songs/mp3.mp3', 'mp3.mp3')
    

Python 3

  • urllib.request.urlopen

      import urllib.request
      response = urllib.request.urlopen('http://www.example.com/')
      html = response.read()
    
  • urllib.request.urlretrieve

      import urllib.request
      urllib.request.urlretrieve('http://www.example.com/songs/mp3.mp3', 'mp3.mp3')
    

Python 2

  • urllib2.urlopen (thanks Corey)

      import urllib2
      response = urllib2.urlopen('http://www.example.com/')
      html = response.read()
    
  • urllib.urlretrieve (thanks PabloG)

      import urllib
      urllib.urlretrieve('http://www.example.com/songs/mp3.mp3', 'mp3.mp3')
    

Python 3

  • urllib.request.urlopen

      import urllib.request
      response = urllib.request.urlopen('http://www.example.com/')
      html = response.read()
    
  • urllib.request.urlretrieve

      import urllib.request
      urllib.request.urlretrieve('http://www.example.com/songs/mp3.mp3', 'mp3.mp3')
    

    Note: According to the documentation, urllib.request.urlretrieve is a "legacy interface" and "might become deprecated in the future" (thanks gerrit)

Python 2

  • urllib2.urlopen (thanks Corey)

      import urllib2
      response = urllib2.urlopen('http://www.example.com/')
      html = response.read()
    
  • urllib.urlretrieve (thanks PabloG)

      import urllib
      urllib.urlretrieve('http://www.example.com/songs/mp3.mp3', 'mp3.mp3')
    
Add Python 2 to have all versions in one place
Source Link
bmaupin
  • 15.6k
  • 6
  • 94
  • 99

Here's how to do it in Python 3 using the standard library:

Python 3

  • urllib.request.urlopen

      import urllib.request
      response = urllib.request.urlopen('http://www.example.com/')
      html = response.read()
    
  • urllib.request.urlretrieve

      import urllib.request
      urllib.request.urlretrieve('http://www.example.com/songs/mp3.mp3', 'mp3.mp3')
    

Python 2

  • urllib2.urlopen (thanks Corey)

      import urllib2
      response = urllib2.urlopen('http://www.example.com/')
      html = response.read()
    
  • urllib.urlretrieve (thanks PabloG)

      import urllib
      urllib.urlretrieve('http://www.example.com/songs/mp3.mp3', 'mp3.mp3')
    

Here's how to do it in Python 3 using the standard library:

  • urllib.request.urlopen

      import urllib.request
      response = urllib.request.urlopen('http://www.example.com/')
      html = response.read()
    
  • urllib.request.urlretrieve

      import urllib.request
      urllib.request.urlretrieve('http://www.example.com/songs/mp3.mp3', 'mp3.mp3')
    

Python 3

  • urllib.request.urlopen

      import urllib.request
      response = urllib.request.urlopen('http://www.example.com/')
      html = response.read()
    
  • urllib.request.urlretrieve

      import urllib.request
      urllib.request.urlretrieve('http://www.example.com/songs/mp3.mp3', 'mp3.mp3')
    

Python 2

  • urllib2.urlopen (thanks Corey)

      import urllib2
      response = urllib2.urlopen('http://www.example.com/')
      html = response.read()
    
  • urllib.urlretrieve (thanks PabloG)

      import urllib
      urllib.urlretrieve('http://www.example.com/songs/mp3.mp3', 'mp3.mp3')
    
Link to latest version of Python 3 docs
Source Link
bmaupin
  • 15.6k
  • 6
  • 94
  • 99

Here's how to do it in Python 3 using the standard library:

Here's how to do it in Python 3 using the standard library:

  • urllib.request.urlopen

      import urllib.request
      response = urllib.request.urlopen('http://www.example.com/')
      html = response.read()
    
  • urllib.request.urlretrieve

      import urllib.request
      urllib.request.urlretrieve('http://www.example.com/songs/mp3.mp3', 'mp3.mp3')
    

Here's how to do it in Python 3 using the standard library:

  • urllib.request.urlopen

      import urllib.request
      response = urllib.request.urlopen('http://www.example.com/')
      html = response.read()
    
  • urllib.request.urlretrieve

      import urllib.request
      urllib.request.urlretrieve('http://www.example.com/songs/mp3.mp3', 'mp3.mp3')
    
Add urllib.request.urlretrieve
Source Link
bmaupin
  • 15.6k
  • 6
  • 94
  • 99
Loading
Source Link
bmaupin
  • 15.6k
  • 6
  • 94
  • 99
Loading