Download files from https server using username and password
Mostra commenti meno recenti
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?
Risposta accettata
Più risposte (1)
Yongjian Feng
il 12 Ago 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 Commenti
sermet OGUTCU
il 12 Ago 2021
Yongjian Feng
il 12 Ago 2021
Modificato: Yongjian Feng
il 12 Ago 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
il 12 Ago 2021
Yongjian Feng
il 12 Ago 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
il 12 Ago 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
il 12 Ago 2021
weiyong yi
il 28 Giu 2023
Doesn't work on my PC at all. Do you have any further ideas?
thank you.
Categorie
Scopri di più su Web Services in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!