Download files from https server using username and password
Afficher commentaires plus anciens
url = 'https://cddis.nasa.gov/archive/gnss/products/0971/';
In this https server, I need to download "cod09710.eph.Z" file for a specific location in my computer. How I can download this file using username and password related to this https server?
Réponse acceptée
Plus de réponses (1)
Yongjian Feng
le 12 Août 2021
Try this:
username = 'Your username here';
password = 'Your password here';
authStr = [username ':' password];
base64Str = ['Basic ' matlab.net.base64encode(authStr)];
headers = {'Authorization': base64Str};
options = weboptions('HeaderFields',headers);
webread('http://ip.jsontest.com', options)
7 commentaires
sermet OGUTCU
le 12 Août 2021
Yongjian Feng
le 12 Août 2021
Modifié(e) : Yongjian Feng
le 12 Août 2021
Try this instead:
username = 'Your username here';
password = 'Your password here';
options = weboptions('Username',username,'Password',password);
webread('http://ip.jsontest.com', options)
sermet OGUTCU
le 12 Août 2021
Yongjian Feng
le 12 Août 2021
Use websave to save it to a file
username = 'Your username here';
password = 'Your password here';
url = 'https://cddis.nasa.gov/archive/gnss/products/0971/';
localfilename = 'Local file to save to';
options = weboptions('Username',username,'Password',password);
websave(localfilename, url, options)
Yongjian Feng
le 12 Août 2021
It will be easier to debug this process using curl in a terminal outside matlab. But
- What has been saved into your local drive? code09710.eph.Z.html? Is it in HTML format? You can go to a terminal and cd to the folder then more code09710.eph.Z.html
- If it is a html, then the wrong file has been downloaded. If it is not a html file, change its extension to .Z and try to unzip it. If you can unzip it, most likely it is the one you want.
sermet OGUTCU
le 12 Août 2021
weiyong yi
le 28 Juin 2023
Doesn't work on my PC at all. Do you have any further ideas?
thank you.
Catégories
En savoir plus sur Web Services dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!