Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6676771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:02:01+00:00 2026-05-26T04:02:01+00:00

I am trying to extract URLs from Google search results. I use Indy IdHTTP

  • 0

I am trying to extract URLs from Google search results. I use Indy IdHTTP to get HTML results from Google, and I use Achmad Z’s code for getting the link hrefs from the page. How can I get the real link target for each URL instead of the one that goes through Google’s redirector?


I tried that but I get an “Operand no applicable” error in this part of the code:

function ToUTF8Encode(str: string): string;
var
  b: Byte;
begin
  for b in BytesOf(UTF8Encode(str)) do
  begin
    Result := Format('%s%s%.2x', [Result, '%', b]);
  end;
end;

I use Delphi 7 with Indy 9.00.10. Maybe indy update will help ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T04:02:02+00:00Added an answer on May 26, 2026 at 4:02 am

    In the previous post here I’ve tried to explain why you should use Google Search API, in this one I’ll try to provide you an example with a hope it will work in your Delphi 7.

    You need to have the SuperObject (JSON parser for Delphi), I’ve used this version (latest at this time). Then you need Indy; the best would be to upgrade to the latest version if possible. I’ve used the one shipped with Delphi 2009, but I think the TIdHTTP.Get method is so important that it must work fine also in your 9.00.10 version.

    Now you need a list box and a button on your form, the following piece of code and a bit of luck (for compatibility 🙂

    The URL request building you can see for instance in the DxGoogleSearchApi.pas mentioned before but the best is to follow the Google Web Search API reference. In DxGoogleSearchApi.pas you can take the inspiration e.g. how to fetch several pages.

    So take this as an inspiration

    uses
      IdHTTP, IdURI, SuperObject;
    
    const
      GSA_Version = '1.0';
      GSA_BaseURL = 'http://ajax.googleapis.com/ajax/services/search/';
    
    procedure TForm1.GoogleSearch(const Text: string);
    var
      I: Integer;
      RequestURL: string;
      HTTPObject: TIdHTTP;
      HTTPStream: TMemoryStream;
      JSONResult: ISuperObject;
      JSONResponse: ISuperObject;
    begin
      RequestURL := TIdURI.URLEncode(GSA_BaseURL + 'web?v=' + GSA_Version + '&q=' + Text);
    
      HTTPObject := TIdHTTP.Create(nil);
      HTTPStream := TMemoryStream.Create;
    
      try
        HTTPObject.Get(RequestURL, HTTPStream);
        JSONResponse := TSuperObject.ParseStream(HTTPStream, True);
    
        if JSONResponse.I['responseStatus'] = 200 then
        begin
          ListBox1.Items.Add('Search time: ' + JSONResponse.S['responseData.cursor.searchResultTime']);
          ListBox1.Items.Add('Fetched count: ' + IntToStr(JSONResponse['responseData.results'].AsArray.Length));
          ListBox1.Items.Add('Total count: ' + JSONResponse.S['responseData.cursor.resultCount']);
          ListBox1.Items.Add('');
    
          for I := 0 to JSONResponse['responseData.results'].AsArray.Length - 1 do
          begin
            JSONResult := JSONResponse['responseData.results'].AsArray[I];
            ListBox1.Items.Add(JSONResult.S['unescapedUrl']);
          end;
        end;
    
      finally
        HTTPObject.Free;
        HTTPStream.Free;
      end;
    end;
    
    procedure TForm1.Button1Click(Sender: TObject);
    begin
      GoogleSearch('Delphi');
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to extract urls from a large number of google search results.
I'm trying to use sed to clean up lines of URLs to extract just
im trying to extract some files from a jar-file downloaded using java-webstart. below code
I'm trying to use the nokogiri gem to extract all the urls on the
I'm trying to extract data from an xml file. A sample of my code
I've been trying to extract URLs from a text file using re api. any
I'm trying to extract the urls from a .htm source, that contains 3 other
I am trying to extract urls from strings. So i've wrote soomething like this:
I am trying to extract album art image from mp3 URLs. I am basically
I'm trying to search a field in a database to extract URLs. Sometimes there

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.