1 (edited by prahousefamily 2025-03-12 04:11:23)

Topic: Example API Get To Domain Name Or WWW

Main Key : Send API By  WinHttp.WinHttpRequest.5.1
https://i.ibb.co/JjdcYKpQ/D20250312-T105820.png


Example Code

var
WinHttpReq : Variant;
procedure Form1_Button1_OnClick (Sender: TObject; var Cancel: boolean);
var
i : Integer ;
url : String ;
StartTime, EndTime: Tdatetime ;
ResponseText: string;
ResponseSize: Integer;
ResponseStatus : Integer ;
Duration: Double;
begin
    Form1.TableGrid1.Columns[5].Alignment :=  taRightJustify ;
    Form1.TableGrid1.Columns[6].Alignment :=  taRightJustify ;
    For i := 0 To Form1.TableGrid1.RowCount - 1 Do
    Begin
        Form1.TableGrid1.ScrollToRow(i);
        Form1.TableGrid1.SelectedRow := i ;
        Form1.TableGrid1.Cells[7,i] := 'Working' ;
        StartTime := NOW;
        url := Form1.TableGrid1.Cells[1,i] ;
        WinHttpReq.Open('GET',url, False);
        WinHttpReq.SetRequestHeader('ContentEncoding','UTF-8');
        Try
            WinHttpReq.Send;
            WinHttpReq.WaitForResponse ;
            ResponseText := WinHttpReq.ResponseText;
            ResponseSize := Length(ResponseText);
            ResponseStatus := WinHttpReq.Status ;
            EndTime := NOW ;
            Duration := (EndTime - StartTime) * 86400000;
            Form1.TableGrid1.Cells[2,i] := IntToStr(ResponseStatus);
            Form1.TableGrid1.Cells[3,i] := FormatDateTime('yyyy-mm-dd hh:mm:ss.zzz',Starttime);
            Form1.TableGrid1.Cells[4,i] := FormatDateTime('yyyy-mm-dd hh:mm:ss.zzz',Endtime);
            Form1.TableGrid1.Cells[5,i] := FormatFloat('0.00', Duration)+' ms' ;
            Form1.TableGrid1.Cells[6,i] := IntToStr(ResponseSize)+' bytes' ;
            Form1.TableGrid1.Cells[7,i] := 'OK' ;
            Except
            Form1.TableGrid1.Cells[7,i] := 'Error' ;
        End;
        Application.ProcessMessages ;
    End;
    Showmessage('Finnish!');
end;
begin
    WinHttpReq := CreateOleObject('WinHttp.WinHttpRequest.5.1');
end.




Note
- Gemini  And  Gemini Code Assist Help Edit Code and Show List Domain Name

Post's attachments

Attachment icon counttime.zip 6.62 kb, 23 downloads since 2025-03-12 

My Visual Database : I Love You
Easy For Beginner Student For Me

Re: Example API Get To Domain Name Or WWW

+ Update Column Duration,Size taRightJustify
+ Update Column Duration,Size Name Value +' ms',+' bytes'
+ Update SetTimeouts 10 second

var
    WinHttpReq : Variant;
procedure Form1_Button1_OnClick (Sender: TObject; var Cancel: boolean);
var
    i : Integer ;
    url : String ;
    StartTime, EndTime: Tdatetime ;
    ResponseText: string;
    ResponseSize: Integer;
    ResponseStatus : Integer ;
    Duration: Double;
begin
    Form1.TableGrid1.Columns[5].Alignment :=  taRightJustify ;
    Form1.TableGrid1.Columns[6].Alignment :=  taRightJustify ;
    For i := 0 To Form1.TableGrid1.RowCount - 1 Do
    Begin                                          
        Form1.TableGrid1.ScrollToRow(i);
        Form1.TableGrid1.SelectedRow := i ;
        Form1.TableGrid1.Cells[7,i] := 'Working' ;
        StartTime := NOW;
        url := Form1.TableGrid1.Cells[1,i] ;
        WinHttpReq.Open('GET',url, False);
        WinHttpReq.SetRequestHeader('ContentEncoding','UTF-8');
        WinHttpReq.SetTimeouts(10000, 10000, 10000, 10000);
        Try
            WinHttpReq.Send;
            WinHttpReq.WaitForResponse ;
            ResponseText := WinHttpReq.ResponseText;
            ResponseSize := Length(ResponseText);
            ResponseStatus := WinHttpReq.Status ;
            EndTime := NOW ;
            Duration := (EndTime - StartTime) * 86400000;
            Form1.TableGrid1.Cells[2,i] := IntToStr(ResponseStatus);
            Form1.TableGrid1.Cells[3,i] := FormatDateTime('yyyy-mm-dd hh:mm:ss.zzz',Starttime);
            Form1.TableGrid1.Cells[4,i] := FormatDateTime('yyyy-mm-dd hh:mm:ss.zzz',Endtime);
            Form1.TableGrid1.Cells[5,i] := FormatFloat('0.00', Duration)+' ms' ;
            Form1.TableGrid1.Cells[6,i] := IntToStr(ResponseSize)+' bytes' ;
            Form1.TableGrid1.Cells[7,i] := 'OK' ;
            Except
            Form1.TableGrid1.Cells[7,i] := 'Error' ;
        End;
        Application.ProcessMessages ;
    End;
    Showmessage('Finnish!');
end;
begin
    WinHttpReq := CreateOleObject('WinHttp.WinHttpRequest.5.1');
end.

Example List URL


| id   | url                                  |
| ---- | ------------------------------------ |
| 1    | https://drive.google.com             |
| 2    | https://www.dropbox.com              |
| 3    | https://onedrive.live.com            |
| 4    | https://mega.nz                      |
| 5    | https://www.pcloud.com               |
| 6    | https://icedrive.net                 |
| 7    | https://www.mediafire.com            |
| 8    | https://www.box.com                  |
| 9    | https://degoo.com                    |
| 10   | https://www.sync.com                 |
| 11   | https://www.infomaniak.com/en/kdrive |
| 12   | https://disk.yandex.com              |
| 13   | https://koofr.eu                     |
| 14   | https://internxt.com                 |
| 15   | https://www.zippyshare.com           |
| 16   | https://upload.ee                    |
| 17   | https://www.filefactory.com          |
| 18   | https://rapidgator.net               |
| 19   | https://uptobox.com                  |
| 20   | https://www.4shared.com              |
| 21   | https://www.sendspace.com            |
| 22   | https://www.terabox.com              |
| 23   | https://wetransfer.com               |
| 24   | https://anonfiles.com                |
| 25   | https://file.io                      |
| 26   | https://uploadfiles.io               |
| 27   | http://send.firefox.com              |
| 28   | https://transferxl.com               |
| 29   | https://fromsmash.com                |
| 30   | https://gofile.io                    |
| 31   | https://filetransfer.io              |
| 32   | https://www.jetdrop.com              |
| 33   | https://tresorit.com/send            |
| 34   | https://wormhole.app                 |
| 35   | https://send-anywhere.com            |
| 36   | https://sharedrop.io                 |
| 37   | https://volafile.org                 |
| 38   | https://catbox.moe                   |
| 39   | https://bayfiles.com                 |
| 40   | https://pixeldrain.com               |
| 41   | https://ufile.io                     |
| 42   | https://send.cm                      |
| 43   | https://onsen.io                     |
| 44   | https://www.swisstransfer.com        |
| 45   | https://www.justbeamit.com           |
| 46   | https://www.filemail.com             |
| 47   | https://www.jumbomail.me             |
| 48   | https://dropmefiles.com              |
| 49   | https://sendgb.com                   |
| 50   | https://www.filedropper.com          |
| 51   | https://tinyupload.com               |
My Visual Database : I Love You
Easy For Beginner Student For Me

Re: Example API Get To Domain Name Or WWW

Set time-outs.
If time-outs are set, they must be set before open.

it doesn't work - Form1.TableGrid1.Cells[7,i] := 'Working' ;

4 (edited by prahousefamily 2025-03-12 12:14:35)

Re: Example API Get To Domain Name Or WWW

sparrow wrote:

Set time-outs.
If time-outs are set, they must be set before open.

it doesn't work - Form1.TableGrid1.Cells[7,i] := 'Working' ;


Thank You  sparrow For recommend Good Code ..

Try Fix

Type Asynchronou

       WinHttpReq.SetTimeouts(10000, 10000, 10000, 10000);
       WinHttpReq.Open('GET',url, True);
       WinHttpReq.SetRequestHeader('Accept-Charset','UTF-8');

Or

Type synchronou

       WinHttpReq.SetTimeouts(10000, 10000, 10000, 10000);
       WinHttpReq.Open('GET',url, False);
       WinHttpReq.SetRequestHeader('Accept-Charset','UTF-8');
My Visual Database : I Love You
Easy For Beginner Student For Me

Re: Example API Get To Domain Name Or WWW

Sorry for the advice
but I would like to advise you to read the documentation of the developers, on the topic of asynchronous mode
and other topics, before writing in the forum an alleged solution.
Gemini and Gemini Code Assist is just an adviser, not a surgeon.

Re: Example API Get To Domain Name Or WWW

sparrow wrote:

Sorry for the advice
but I would like to advise you to read the documentation of the developers, on the topic of asynchronous mode
and other topics, before writing in the forum an alleged solution.
Gemini and Gemini Code Assist is just an adviser, not a surgeon.

Always welcome for advice, with love and respect. sparrow Good Friend

My Visual Database : I Love You
Easy For Beginner Student For Me