Perform a web search through Matlab and get back the results
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
DGM
el 4 de Abr. de 2023
Editada: DGM
el 4 de Abr. de 2023
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 comentarios
Ver también
Categorías
Más información sobre JSON Format en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!