mql5 - 试图将网站的内容复制到字符串中进行分析
问题描述
所以我正在为 mt5 平台的新闻过滤专家编写代码。这就是代码的工作方式,下载 html 页面,将页面内容复制到字符串中,然后使用该字符串进行分析。
到目前为止,我已经成功下载了 html 页面,现在主要的问题是将 html 页面的内容复制到字符串中以帮助我的分析。请帮助
int filehandle2=FileOpen("news-log.html",FILE_READ|FILE_BIN); TXT=FileReadString(filehandle2,ArraySize(result));
解决方案
试试下面的代码,它应该可以工作。
string str;
int file_handle=FileOpen("news-log.html",FILE_READ|FILE_BIN|FILE_ANSI);
if(file_handle!=INVALID_HANDLE)
{
str=FileReadString(file_handle,int(FileSize(file_handle)));
FileClose(file_handle);
}
else PrintFormat("Failed to open %s file, Error code = %d","news-log.html",GetLastError());