How ca n I get a table from web page?

5 ビュー (過去 30 日間)
Adriano
Adriano 2022 年 11 月 11 日
コメント済み: Adriano 2022 年 11 月 14 日
Hi all,
I need to get the table from this url: https://www.cambriafunds.com/tail-holdings
I tried using webread fuction but it doesn't work (I think because webread function capture html code before the table appears). Furthermore, I can't use getTableFromWeb function because in Matlab 2022b I can't open Matlab browser. Someone can help me? Many thanks!
Regards

回答 (1 件)

Bhavana Ravirala
Bhavana Ravirala 2022 年 11 月 14 日
There is no built-in function to read and parse web pages directly into MATLAB.
However, tabular values are often marked with tags such <TR>, <TD>, or <LI>. One possible workflow is as follows:
1. Read the HTML code from the website by using the URLREAD function in MATLAB.
2. Use string parsing functions such as STRFIND to identify the indices of the start and end tags (e.g. <TR> and </TR>) for a particular field.
3. Use these indices to split up the text in each row and store the data to a cell array in MATLAB.
4. Use regular expressions via the REGEXP function to perform any additional postprocessing, as necessary.
To get the HTML table data into MATLAB via URLREAD refer the below link:
  1 件のコメント
Adriano
Adriano 2022 年 11 月 14 日
It doesn't work because Matlab has a big big problem: urlread and webread functions capture data from a web page before it is completly loaded. So, for example, if I execute this code:
out_table = getTableFromWeb_mod('https://www.cambriafunds.com/tail-holdings', 1)
the output is:
out_table =
1×1 cell array
{'No Table detected.'}
and the same occur using:
output = webread('https://www.cambriafunds.com/tail-holdings')
thisproblem has been discussed by other users, for example:
However Matlab after many years seems enable to find a solution. Regards

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeWeb Services についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by