I'm trying to retrieve a content of HTTP document with MS XMLHTTP COM. I did copied the following sample code but even this does not work and fails with EOLEException error 'Access is denied' at send method call.
uses
MSXML, ComObj, ActiveX;
procedure TForm1.Button1Click(Sender: TObject);
var
httpDoc: XMLHTTP; // IXMLHTTPRequest
begin
httpDoc := CreateOleObject('MSXML2.XMLHTTP') as XMLHTTP;
try
httpDoc.open('GET', 'http://www.google.com/index.html', False, EmptyParam, EmptyParam);
httpDoc.send(''); // <-- EOLEException 'Access is denied'
if (httpDoc.readyState = 4) and (httpDoc.status = 200) then
ShowMessage(httpDoc.responseText);
finally
httpDoc := nil;
end;
end;
I really don't know what am I doing wrong :(
Google does location-based redirections, and sometimes that involves redirecting to another domain. XMLHTTP
does not like that. Also, it seems XMLHTTP
does not allow access to remote servers when running from a local script (such as from VB, Delphi, etc) outside of a browser. See this discussion, this discussion, and this documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With