Download files from https server using username and password
显示 更早的评论
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?
采纳的回答
更多回答(1 个)
Yongjian Feng
2021-8-12
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 个评论
sermet OGUTCU
2021-8-12
Yongjian Feng
2021-8-12
编辑:Yongjian Feng
2021-8-12
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
2021-8-12
Yongjian Feng
2021-8-12
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
2021-8-12
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
2021-8-12
weiyong yi
2023-6-28
Doesn't work on my PC at all. Do you have any further ideas?
thank you.
类别
在 帮助中心 和 File Exchange 中查找有关 Web Services 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!