Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
URL reading

Subject: URL reading

From: AHMET ANIL DINDAR

Date: 29 Oct, 2010 18:09:04

Message: 1 of 5

Hi all,
I'd like to read a specific part of a web page. In html code, it is placed between <pre> and </pre>.
I tried using "urlread" in MATLAB but it seems it takes me to somewhere complicated.

Any idea?

Ahmet

Subject: URL reading

From: Sean

Date: 29 Oct, 2010 18:24:03

Message: 2 of 5

"AHMET ANIL DINDAR" <adindar@iku.edu.tr> wrote in message <iaf2k0$ghb$1@fred.mathworks.com>...
> Hi all,
> I'd like to read a specific part of a web page. In html code, it is placed between <pre> and </pre>.
> I tried using "urlread" in MATLAB but it seems it takes me to somewhere complicated.
>
> Any idea?
>
> Ahmet

Use STRFIND to find the first '<pre>' and the first '</pre>'

Here's a snippet from my function GUNITS on the FEX which does just this only looking for <b>.
S = urlread...

strinit = strfind(lower(S),'<b>');
strend = strfind(lower(S),'</b>');
if isempty(strinit) || isempty(strend)
    error('Please try again!');
end
strinit = strinit(1);
strend = strend(strend>strinit);
strend = strend(1);

%Output the answer (remove the <b>, < found earlier)
outStr = S(strinit+3:strend-1);

Subject: URL reading

From: Oleg Komarov

Date: 29 Oct, 2010 18:30:09

Message: 3 of 5

"AHMET ANIL DINDAR" <adindar@iku.edu.tr> wrote in message <iaf2k0$ghb$1@fred.mathworks.com>...
> Hi all,
> I'd like to read a specific part of a web page. In html code, it is placed between <pre> and </pre>.
> I tried using "urlread" in MATLAB but it seems it takes me to somewhere complicated.
>
> Any idea?
>
> Ahmet

use urlread and then regexp to match the <pre> </pre> pattern (there is an example on how to do that).

Oleg

Subject: URL reading

From: AHMET ANIL DINDAR

Date: 29 Oct, 2010 18:40:07

Message: 4 of 5

Sean hi,
Thank you for your prompt reply.
It cured my problem.

Greetings from Istanbul

Ahmet

============================
"knowledge is power, sharing is the wisdom"
############################

Subject: URL reading

From: AHMET ANIL DINDAR

Date: 29 Oct, 2010 18:50:04

Message: 5 of 5

Oleg hi,
Thanks for your reply. I'll try your code, too.

Ahmet

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us