Posted by: afrocuban
« on: January 04, 2024, 11:01:56 pm »
Custom field, here:
//Get ~Metascore~
EndPos:=Pos('</span></span><span class="label"><span class="metacritic-score-label">Metascore</span></span></span></a></li></ul>',HTML);
if EndPos>0 then begin
curPos:=PrevPos('">',HTML,EndPos)+Length('">');
EndPos:=PosFrom('</span></span><span class="label"><span class="metacritic-score-label">Metascore</span></span></span></a></li></ul>',HTML,curPos)+2;
//ItemValue:=RemoveTags(Copy(HTML,curPos,endPos-curPos),false);
ItemValue:=Copy(HTML,curPos,endPos-curPos);
LogMessage(' Get result Metascore 0:'+ItemValue+'||');
ItemValue:=StringReplace(ItemValue,'0</',',0',True,False,True);
ItemValue:=StringReplace(ItemValue,'1</',',1',True,False,True);
ItemValue:=StringReplace(ItemValue,'2</',',2',True,False,True);
ItemValue:=StringReplace(ItemValue,'3</',',3',True,False,True);
ItemValue:=StringReplace(ItemValue,'4</',',4',True,False,True);
ItemValue:=StringReplace(ItemValue,'5</',',5',True,False,True);
ItemValue:=StringReplace(ItemValue,'6</',',6',True,False,True);
ItemValue:=StringReplace(ItemValue,'7</',',7',True,False,True);
ItemValue:=StringReplace(ItemValue,'8</',',8',True,False,True);
ItemValue:=StringReplace(ItemValue,'9</',',9',True,False,True);
//curPos:=Pos('var ue_t0=ue_t0',ItemValue); //WEB_SPECIFIC.
//If 0<curPos then ItemValue:=Copy(ItemValue,0,curPos-1);
if ItemValue <> '' then AddCustomFieldValueByName('Metascore',FloatToStr((StrToFloat(ItemValue) * 1)));
if ItemValue <> '' then LogMessage(' Get result Metascore (CF~Metascore~):'+ItemValue+'||');
End;
//(*
LogMessage(#13+'');
Thank you in advance.