|
|
void OnStart()
{
string cookie=NULL,headers;
char post[],result[];
int res;
string Contact="1354167644";
string google_url="https://www.google.com/finance";
ResetLastError();
//--- 载入页面
int timeout=5000;
res=WebRequest("GET",google_url,cookie,NULL,timeout,post,0,result,headers);
//---
if(res==-1)
{
Print("Error in WebRequest. Error code =",GetLastError());
}
else
{
PrintFormat("The file has been successfully loaded, File size =%d bytes.",ArraySize(result));
//--- 保存文件
int filehandle=FileOpen("GoogleFinance.htm",FILE_WRITE|FILE_BIN);
//--- 查错
if(filehandle!=INVALID_HANDLE)
{
FileWriteArray(filehandle,result,0,ArraySize(result));
//---关句柄
FileClose(filehandle);
}
else Print("Error in FileOpen. Error code=",GetLastError());
}
}复制代码 |
|