If you made a script you can offer it to the others here, or ask help to improve it. You can also report here bugs & problems with existing scripts.
lukecs
Posts: 21 Joined: 2002-07-25 03:38:29
Location: Calgary, Canada
Contact:
Post
by lukecs » 2002-07-30 00:58:21
I like to see users comments when I look for a movie on imdb. So I added this code to the imdb script so that the users comment went in the comment field
Code: Select all
// Comments
LineNr := FindLine('Summary:</B>', Page, 0);
if LineNr > -1 then
begin
LineNr := LineNr + 1;
Line := Page.GetString(LineNr);
BeginPos := pos('<P>', Line) + 3;
repeat
LineNr := LineNr + 1;
Line := Line + Page.GetString(LineNr);
EndPos := pos('</P>', Line);
until EndPos > 0;
Value := copy(Line, BeginPos, EndPos - BeginPos);
HTMLDecode(Value);
SetField(fieldComments, Value);
end;
antp
Site Admin
Posts: 9639 Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:
Post
by antp » 2002-07-30 09:20:10
Thanks
I just added this :
Code: Select all
Value := StringReplace(Value, '<BR>', #13#10);
before the "setField" instruction, since for some movies there are line breaks (e.g. for Matrix)
lukecs
Posts: 21 Joined: 2002-07-25 03:38:29
Location: Calgary, Canada
Contact:
Post
by lukecs » 2002-07-30 10:43:44
cool thanks
Just some additional questions
-whats with #13#10?
-Where does the function HTMLDecode come from?
antp
Site Admin
Posts: 9639 Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:
Post
by antp » 2002-07-30 11:47:32
HTMLDecode remplace things like "é" by "é", etc...
#13#10 is a linebreak. Under Windows the linebreaks are stored on two bytes, that have the ASCII values 13 and 10 (the 32 first ASCII values are special things, non-printable characters. From 32 to 255 they are the standard characters and symbols).
lukecs
Posts: 21 Joined: 2002-07-25 03:38:29
Location: Calgary, Canada
Contact:
Post
by lukecs » 2002-07-30 11:48:06
I found that the script returned nothing if the one line summary was longer than one line. Here is the script again with both corrections
Code: Select all
// Comments
LineNr := FindLine('Summary:</B>', Page, 0);
if LineNr > -1 then
begin
BeginPos := 0;
repeat
LineNr := LineNr + 1;
Line := Page.GetString(LineNr);
BeginPos := pos('<P>', Line);
until BeginPos > 0;
BeginPos := BeginPos + 3;
repeat
LineNr := LineNr + 1;
Line := Line + Page.GetString(LineNr);
EndPos := pos('</P>', Line);
until EndPos > 0;
HTMLDecode(Value);
Value := copy(Line, BeginPos, EndPos - BeginPos);
Value := StringReplace(Value, '<BR>', #13#10);
SetField(fieldComments, Value);
end;
antp
Site Admin
Posts: 9639 Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:
Post
by antp » 2002-07-30 12:13:16
Thanks
But the HTMLDecode has to be done before the Value := copy... since if you do it before it will do nothing (value is empty)