gpt4 book ai didi

matlab - 如何使用 Matlab 中的 StackExchange API?

转载 作者:太空宇宙 更新时间:2023-11-03 20:16:42 25 4
gpt4 key购买 nike

如何使用 Matlab 从 StackExchange API 访问数据?

天真

sitedata = urlread('http://api.stackoverflow.com/1.1/questions?tagged=matlab')

失败,因为数据被压缩了。但是,当我将其写入文件时(使用 fprintf(fileID,'%s',sitedata)),我得到了一个无法解压缩的 zip 文件。

最佳答案

尝试使用 urlwrite() 代替:

urlwrite('http://api.stackoverflow.com/1.1/questions?tagged=matlab',...
'tempfile.zip')
gunzip('tempfile.zip')
fid = fopen('tempfile');
str = textscan(fid,'%s',Delimiter','\n');
fclose(fid);

此代码段的更好版本是使用 tempname 动态生成临时文件名。

关于matlab - 如何使用 Matlab 中的 StackExchange API?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14248406/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com