Download files from https server using username and password
Show older comments
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?
Accepted Answer
More Answers (1)
Yongjian Feng
on 12 Aug 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 Comments
sermet OGUTCU
on 12 Aug 2021
Yongjian Feng
on 12 Aug 2021
Edited: Yongjian Feng
on 12 Aug 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
on 12 Aug 2021
Yongjian Feng
on 12 Aug 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
on 12 Aug 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
on 12 Aug 2021
weiyong yi
on 28 Jun 2023
Doesn't work on my PC at all. Do you have any further ideas?
thank you.
Categories
Find more on Web Services in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!