Показать сообщение отдельно
  #1  
Старый 08.01.2019, 21:01
terskovma terskovma вне форума
Прохожий
 
Регистрация: 08.01.2019
Сообщения: 4
Версия Delphi: Delphi 10.3
Репутация: 10
По умолчанию webbrowser сохранить картинку с капчей

Доброе время суток. Подскажите Как с Twebbrowser вытащить картинку с капчей.
Пробовал из кэша по примеру из интернета
капча Solve Media
Код:
 procedure SaveImageFromIHtmlDocument2(AIHtmlDocument2: IHtmlDocument2; const ADir: string);
var Images: IHTMLElementCollection;
    i, P: Integer;
    ImgElement: IHTMLImgElement;
    Buff: Pointer;
    BuffSize: DWORD;
    URL: String;
    NewName: string;
    ElementRender: IHTMLElementRender;
    Bitmap: TBitmap;
begin
 if not Assigned(AIHtmlDocument2) then exit;
  Images := AIHtmlDocument2.images;
  if not Assigned(Images) then exit;

  for i := 0 to Images.length - 1 do
  if Succeeded(Images.item(i, 0).QueryInterface(IHTMLImgElement, ImgElement)) then
  try
    URL := ImgElement.src;
    NewName := URL;
    P := LastDelimiter('/', NewName);
    if P > 0 then Delete(NewName, 1, P);
    NewName := ChangeFileExt(ADir + inttostr(i), '.png');
    Buff := nil;
    BuffSize := 0;
    if not RetrieveUrlCacheEntryFile(PChar(URL), TInternetCacheEntryInfo(Buff^), BuffSize, 0) and (GetLastError = ERROR_INSUFFICIENT_BUFFER) then
    begin
      GetMem(Buff, BuffSize);
      try
        if RetrieveUrlCacheEntryFile(PChar(URL), TInternetCacheEntryInfo(Buff^), BuffSize, 0) then
        try
          if Succeeded(ImgElement.QueryInterface(IHTMLElementRender, ElementRender)) then
          try
            Bitmap := TBitmap.Create;
            try
              with ImgElement as IHTMLElement, Bitmap, Canvas do
              begin
                Width := offsetWidth;
                Height := offsetHeight;
                Brush.Color := clWhite;
                FillRect(ClipRect);
                ElementRender.DrawToDC(Handle);
                SaveToFile(NewName);
              end;
            finally
              Bitmap.Free;
            end;
          finally
            ElementRender := nil;
          end;
        finally;
        end;
      finally
        ImgElement := nil;
      end;
    end;
  finally
  end;
end;
сохраняет все кроме нужной картинки
Поиск по форуму побывал, и гугл не помог
Сайт где пытаюсь картинку вытащить http://moonbit.co.in/
подскажите куда смотреть что не так делаю
Ответить с цитированием