More then one genre?

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.
Post Reply
DrSwede

More then one genre?

Post 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
antp
Site Admin
Posts: 9651
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post 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)
DrSwede

Post 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:
Yanch
Posts: 7
Joined: 2002-09-18 13:18:18
Location: Israel

Post 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;
antp
Site Admin
Posts: 9651
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

IMDB changed their site yesterday, that's why you had to modify that ;)
Yanch
Posts: 7
Joined: 2002-09-18 13:18:18
Location: Israel

Post by Yanch »

Hmm, lucky me :)
Post Reply