XMLHTTP Error and Access Denied

I am trying to get the contents of an HTTP document with MS XMLHTTP COM. I copied the following code sample, but even this does not work and does not execute with the EOLEException "Access denied" error when calling the send method.

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 I'm doing wrong :(

+6
source share
1 answer

Google performs location-based redirects, and sometimes redirects them to another domain. XMLHTTP not pleasant. In addition, it seems that XMLHTTP does not allow access to remote servers when launched from a local script (for example, from VB, Delphi, etc.) Outside the browser. See this discussion , this discussion, and this documentation .

+5
source

Source: https://habr.com/ru/post/904715/


All Articles