Page 1 of 1

More then one genre?

Posted: 2002-08-01 19:10:35
by DrSwede
Is there any way to change the script to import all genres? (if more than one) i.e Genre: Comedy / Family / Fantasy

Code: Select all

  //Category
  LineNr := FindLine('Genre</B>', Page, 0);
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr);
    BeginPos := pos('/">', Line) + 3;
    EndPos := pos('</A>', Line);
    Value := copy(Line, BeginPos, EndPos - BeginPos);
    HTMLDecode(Value);
    SetField(fieldCategory, Value);
  end;
This is the HTML:

Code: Select all

<B CLASS="ch">Genre</B>: <A HREF="/Sections/Genres/Comedy/">Comedy</A>  / <A HREF="/Sections/Genres/Family/">Family</A>  / <A HREF="/Sections/Genres/Fantasy/">Fantasy</A> <A HREF="/Keywords?0243585"> (more)</A><BR><BR>
Thanks in advance

Posted: 2002-08-01 19:24:40
by antp
sure

Code: Select all

  //Category
  LineNr := FindLine('Genre</B>', Page, 0);
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr);
    BeginPos := pos('/">', Line) + 3;
    EndPos := pos('</A><BR><BR>', Line);
    Value := copy(Line, BeginPos, EndPos - BeginPos);
    HTMLRemoveTags(Value);
    HTMLDecode(Value);
    SetField(fieldCategory, Value);
  end;
This may work (I haven't tried it)

Posted: 2002-08-01 20:25:15
by DrSwede
Thanks! I didn't know it was gonna be that easy... ;)
I changed it a little, just to get rid of the "(more)"
It works like a charm

Code: Select all

//Category 
  LineNr := FindLine('Genre</B>', Page, 0); 
  if LineNr > -1 then 
  begin 
    Line := Page.GetString(LineNr); 
    BeginPos := pos('/">', Line) + 3; 
    EndPos := pos('</A> <A HREF="/Keywords', Line); 
    Value := copy(Line, BeginPos, EndPos - BeginPos); 
    HTMLRemoveTags(Value); 
    HTMLDecode(Value); 
    SetField(fieldCategory, Value); 
  end; 
Thanks again for the reply and a very good program! :grinking:

Posted: 2002-09-18 13:47:00
by Yanch
Somehow, the code above didn't work for me, so I've changed it a little:

Code: Select all

  //Category
  LineNr := FindLine('Genre:', Page, 0);
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr + 1);
    BeginPos := pos('/">', Line) + 3;
    EndPos := pos('</a> <a href="/Keywords', Line);
    Value := copy(Line, BeginPos, EndPos - BeginPos);
    HTMLRemoveTags(Value);
    HTMLDecode(Value);
    SetField(fieldCategory, Value);
  end;

Posted: 2002-09-18 13:55:46
by antp
IMDB changed their site yesterday, that's why you had to modify that ;)

Posted: 2002-09-18 14:05:49
by Yanch
Hmm, lucky me :)