Guest User

Untitled

a guest
Feb 5th, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. import urllib2
  2.  
  3. username = 's5pguest'
  4. password = 's5pguest'
  5.  
  6. #This should be the base url you wanted to access.
  7. baseurl = "https://s5phub.copernicus.eu/dhus/odata/v1/Products('56c22bb9-f91d-40de-9bc8-3ddf23fc2fb0')/$value"
  8.  
  9. #Create a password manager
  10. manager = urllib2.HTTPPasswordMgrWithDefaultRealm()
  11. manager.add_password(None, baseurl, username, password)
  12.  
  13. #Create an authentication handler using the password manager
  14. auth = urllib2.HTTPBasicAuthHandler(manager)
  15.  
  16. #Create an opener that will replace the default urlopen method on further calls
  17. opener = urllib2.build_opener(auth)
  18. urllib2.install_opener(opener)
  19.  
  20. #Here you should access the full url you wanted to open
  21. response = urllib2.urlopen(baseurl + "/file")
Add Comment
Please, Sign In to add comment