Thanks in advance
Antony
try this:
#import "wininet.dll" int InternetOpenW(string,int,string,string,int); int InternetConnectW(int,string,int,string,string,int,int,int); int InternetOpenUrlW(int,string,string,int,int,int); int InternetReadFile(int hFile,uchar &sBuffer[],int lNumBytesToRead,int &lNumberOfBytesRead[]); int InternetCloseHandle(int); #import string GrabWeb(string strUrl) {//>4 string result; int HttpOpen=InternetOpenW(" ",0," "," ",0); int HttpConnect = InternetConnectW(HttpOpen, "", 80, "", "", 3, 0, 1); int HttpRequest = InternetOpenUrlW(HttpOpen,strUrl, NULL, 0, 0, 0); int read[1]; int sz=0; uchar buffer[1024]; bool isOk; while(true) { isOk = InternetReadFile(HttpRequest,buffer,1024,read); sz += read[0]; if(read[0]>0) result=result+CharArrayToString(buffer,0,read[0],CP_UTF8); else break; } if(HttpRequest>0) InternetCloseHandle(HttpRequest); if(HttpConnect>0) InternetCloseHandle(HttpConnect); if(HttpOpen>0) InternetCloseHandle(HttpOpen); if (sz>0) return (result); // else return(""); }
( I changed my code and didn't compile it..!)
Works perfectly, thank you so much.
Antony
I have no idea.
And I think even if I would know more about the Server and the files loaded I wouldn't know.
Could it be a local (your pc) Internet buffer or could it be buffered by your internet provider?
On the old script it uses this:
Wonder if this can be used in the GrabWeb() function?
int hReq = InternetOpenUrlW(hSession, fUrl, "0", 0, INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_PRAGMA_NOCACHE | INTERNET_FLAG_RELOAD, 0 );
#define INTERNET_FLAG_NO_CACHE_WRITE 0x04000000 #define INTERNET_FLAG_PRAGMA_NOCACHE 0x00000100
Thanks again
Antony
tonyjms2005:
Wonder if this can be used in the GrabWeb() function?
yes
Ah right cool, like this:
#define INTERNET_FLAG_NO_CACHE_WRITE 0x04000000 string GrabWeb(string strUrl) {//>4 string result; int HttpOpen=InternetOpenW(" ",0," ",INTERNET_FLAG_NO_CACHE_WRITE,0); int HttpConnect = InternetConnectW(HttpOpen, "", 80, "", "", 3, 0, 1); int HttpRequest = InternetOpenUrlW(HttpOpen,strUrl, NULL, 0, 0, 0); int read[1]; int sz=0; uchar buffer[1024]; bool isOk; while(true) { isOk = InternetReadFile(HttpRequest,buffer,1024,read); sz += read[0]; if(read[0]>0) result=CharArrayToString(buffer,0,read[0],CP_UTF8); else break; } //if(HttpRequest>0) InternetCloseHandle(HttpRequest); // if(HttpConnect>0) InternetCloseHandle(HttpConnect); // if(HttpOpen>0) InternetCloseHandle(HttpOpen); if (sz>0) Print("res",result);return (result); // else return(""); }
string GrabWeb2(string strUrl) {//>4 int HttpOpen=InternetOpenW(" ",0," "," ",0); int HttpConnect = InternetConnectW(HttpOpen, "", 80, "", "", 3, 0, 1 ); //int HttpRequest = InternetOpenUrlW(HttpOpen,strUrl, NULL, 0, 0, 0 ); int HttpRequest = InternetOpenUrlW(HttpOpen, strUrl, "0", 0, INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_PRAGMA_NOCACHE, 0 ); string result: int read[1]; int sz=0; uchar buffer[1024]; bool isOk; while(true) { isOk = InternetReadFile(HttpRequest,buffer,1024,read); sz += read[0]; if(read[0]>0) result=result+CharArrayToString(buffer,0,read[0],CP_UTF8); else break; } /*if(HttpRequest>0)*/ InternetCloseHandle(HttpRequest); /*if(HttpConnect>0)*/ InternetCloseHandle(HttpConnect); /*if(HttpOpen>0)*/ InternetCloseHandle(HttpOpen); if (sz>0) { Print("res: ",result); return(result); } return(""); }
This I could compile without error, but haven't checked it working.
Can you tell me whether you still have the chache-problem?
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi
After upgrading to 600 build I am experiencing issues with my function that otherwise work perfectly.
It returns a 1004 code and records in the log: "Error when calling InternetOpenUrlA()"
Here is the code, can anyone please help: