我正在使用MQL4开发一个程序,这需要从特定网页中提取一些数据片段。
如何每5分钟将其转储到.csv
文件中?
我被困在怎样才能解决这个问题。
.html
页面转储的一些数据.csv
文件由于你的问题是如此笼统(不是特定的编码问题),而且它太广泛了。我将提供一个概括性的答案,指出你正确的方向。你需要做自己的研究。
第1部分 - 安排活动
EventSetTimer(5*60)
创建一个计时器。OnTimer()
活动中,请致电您的下载程序(参见第2部分)第2部分 - 下载HTML
Wininet.DLL
具有适合此的API:
import "wininet.dll" //Put a # in-front of import
int InternetAttemptConnect (int x);
int InternetOpenW(string sAgent, int lAccessType,
string sProxyName = "", string sProxyBypass = "",
int lFlags = 0);
int InternetOpenUrlW(int hInternetSession, string sUrl,
string sHeaders = "", int lHeadersLength = 0,
int lFlags = 0, int lContext = 0);
int InternetReadFile(int hFile, int& sBuffer[], int lNumBytesToRead,
int& lNumberOfBytesRead[]);
int InternetCloseHandle(int hInet);
import //Put a # in-front of import
OpenW
创建浏览器会话,然后使用OpenURLW
打开URL,然后使用ReadFile API读取页面内容;最后,与CloseHandle
结束会议。第3部分 - 写入.CSV
要执行文件写入操作,您将查看FileOpen()
,FileWriteString()
和FileClose()
MQL4函数。
第4部分 - 阅读.CSV
FileReadString()
一样简单。StringSplit()
函数将字符串拆分为CSV。.ex4
(ZMQ具有适用于许多生产级环境的端口/包装器,因此可以将MQL4集成到任何需求中Check this and other MQL4/ZeroMQ posts on Stack Overflow
Another MQL4 Real-time output, being remote-logged and animated