I'm trying to figure how to parse the Rank, Title and URL of a Google search result using Delphi.
Mainly i need to get all the A links and TEXT from an H3 Tag with a specific class name "r".
Here is the function to get the results section of the Google html:
function TForm1.ExtractContainer: TStringList;
var
Doc : IHTMLDocument3;
i: Integer;
Download: IHTMLElement;
Coll: IHTMLElementCollection;
Anchor: IHTMLAnchorElement;
tmp : String;
begin
Result := TStringList.Create;
Doc := EmbeddedWB1.Document as IHTMLDocument3;
Download := Doc.getElementById('center_col') as IHTMLElement;
tmp := Download.innerHTML;
result.Text := AnsiReplaceStr(tmp, '<h3 class="r">', '<h3 class="r">'#13#10);
for i := 1 to result.Count -1 do
begin
tmp := ExtractTextBetween (result[i], 'href="','">');
memo1.Lines.Add(tmp);
end;
As you can see in the div id center_col
are all the Google Results. Now i need to do some kind of look to get all the A links and TEXT from an H3 Tag with a specific class name "r".
Hope that someone can help me!