SRL Archive - Other Scripts

Reading text from a webpage


tryxter

2007-07-16 17:56:10

Hi!

I'm new with SCAR. I'm trying to read some text from a webpage frame. I've selected the frame with the window selector and I was trying to select the text using the GetTextAtEx() function, but I can't get it working.

Can anyone give me an example on how to read text from web browser page?

Thanks a lot!

Jason2gs

2007-07-16 19:36:41

A web page? Quite simple: GetPage();

Here's an example.

program New;

var
Text: String;

begin
Text := GetPage('http://www.google.com');
Writeln(Text);
end.

And parsing would be something like this:

program New;

var
Text: String;
SubString: String;
Position: Integer;

begin
Text := GetPage('http://www.google.com');
Writeln(Text);
SubString := 'charset=ISO-8859-1"><title';
Position := Pos(SubString, Text);
Writeln(IntToStr(Position);
Delete(Text, 1, Position + Length(SubString));
Writeln(Text);
SubString := 'Google<';
Position := Pos(SubString, Text);
Writeln(IntToStr(Position));
Delete(Text, Length(SubString), Length(Text));
Writeln(Text);
end.

It's a bit sloppy, but you get the idea :)

I hope that was what you were looking for!

tryxter

2007-07-16 19:58:22

Well, that isn't the best option to me because I'll have to do it repeatedly. My objective is to use the GetTextAtEx() or something, but I can't get it to work.

Anyway, I would like to try the GetPage() but it's difficult too, because it's a frame that I want and I need to login to that page too, so it would be a lot easier to use the GetTextAtEx() or a similar function.

Thanks a lot! :)