Borrar filtros
Borrar filtros

Harvest data from a website

2 visualizaciones (últimos 30 días)
Khalala Mamouri
Khalala Mamouri el 16 de Sept. de 2020
Respondida: Xavier el 16 de Sept. de 2020
Hi ,
I am looking for a way to retreive data from a web site to built a database for my app. What i want to do is to get for exemple : Thermal Resistance @ Forced Air Flow
from the this website :
https://www.digikey.com/products/en/fans-thermal-management/thermal-heat-sinks/219
I found this forum https://www.mathworks.com/matlabcentral/answers/400522-retrieving-data-from-a-web-page but i dont know why it does not work for me. maybe if someone helps me with an exemple to extract Thermal Resistance @ Forced Air Flow could help me
thank you

Respuesta aceptada

Xavier
Xavier el 16 de Sept. de 2020
There are admittedly more glamourous ways of doing this, but this works
% Get the html for the webpage
html = webread("https://www.digikey.com/products/en/fans-thermal-management/thermal-heat-sinks/219");
% find the start and end of the data and remove the rest
iStart = strfind(html, "Thermal Resistance @ Forced Air Flow");
iStart = iStart(1);
iEnd = strfind(html, "Thermal Resistance @ Natural");
iEnd = iEnd(1);
html = html(iStart:iEnd);
% get the indexes of the start and finish of the data points
iStart = strfind(html, "<option value") +23;
iEnd = strfind(html, "</option")-1;
% pre-allocate results
results = strings(numel(iStart), 1);
% write and clean up results
for i = 1:numel(results)
results(i) = string(html(iStart(i):iEnd(i)));
results(i) = strrep(results(i), " ", "");
results(i) = strip(results(i));
end

Más respuestas (0)

Categorías

Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by