Perform a web search through Matlab and get back the results
5 次查看(过去 30 天)
显示 更早的评论
Hello,
I would like to perform a search in a website (every time searching different terms) and get results in matlab platform.
Do you know any easy and reliable method to perform this?
Thanks in advance.
LK
0 个评论
回答(1 个)
DGM
2023-4-4
编辑:DGM
2023-4-4
There are probably better ways, but here's one example I pulled from something else I wrote.
This relies on Google's JSON API. You'll need to read about how to set that up.
apikey = '12345'; % your API key
cx = '12345'; % your search engine ID
query = 'delicious spiders'; % the search query
wopt = weboptions('contenttype','json');
url = ['https://customsearch.googleapis.com/customsearch/v1?cx=' cx '&key=' apikey '&q=' query '&num=10'];
try
S = webread(url,wopt);
catch
% this might also happen if no exact url exist and API call is broken somehow
fprintf('Connection error. Web search failed.\n')
return;
end
Your results will be in the struct S.
Considering that getting relevant results from search engines is often difficult to impossible, I would posit that there is no such thing as a reliable option, regardless of how consistently they might execute without overt error.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Web Services 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!