outfilename = websave(filename,url) 保存来自 url 指定的 Web 服务的内容,并将其写入 filename。websave 函数将完整的 filename 路径以 outfilename 形式返回。
语法:
outfilename = websave(filename,url)
outfilename = websave(filename,url,QueryName1,QueryValue1,...,QueryNameN,QueryValueN)
outfilename = websave(___,options)
如何从 Web 服务器文件保存数据:
httpsUrl = "https://requestserver.mathworks.com";
dataUrl = strcat(httpsUrl, "/assets/weatherStation.csv");
weatherFile = "weatherData.csv";
weatherFileFullPath = websave(weatherFile, dataUrl);
如何将数据保存为文本文件:
httpUrl = 'http://requestserver.mathworks.com';
employeeUrl = strcat(httpUrl, '/employee');
employeeFile = 'employeeData.txt';
employeeFileFullPath = websave(employeeFile, employeeUrl, 'occupation', 'Software Engineer');
employeeData = jsondecode(fileread(employeeFileFullPath))
如何将 Web 服务器上的一个图像保存为文件:
httpsUrl = "https://requestserver.mathworks.com";
imageUrl = strcat(httpsUrl, "/assets/computerVision.jpg");
imageFile = "computerVision.jpg";
imageFileFullPath = websave(imageFile, imageUrl);