Perform a web search through Matlab and get back the results

조회 수: 19 (최근 30일)
lefteris
lefteris 2023년 4월 4일
편집: DGM 2023년 4월 4일
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

답변 (1개)

DGM
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.

카테고리

Help CenterFile Exchange에서 Web Services에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by