質問編集履歴
1
コードの修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -7,27 +7,68 @@
|
|
7
7
|
### 該当のソースコード
|
8
8
|
|
9
9
|
```MQL4
|
10
|
+
int OnInit()
|
11
|
+
{
|
12
|
+
EventSetTimer(1);
|
13
|
+
return(INIT_SUCCEEDED);
|
14
|
+
}
|
15
|
+
|
16
|
+
void OnDeinit(const int reason)
|
17
|
+
{
|
18
|
+
EventKillTimer();
|
19
|
+
}
|
20
|
+
|
21
|
+
void OnTimer()
|
22
|
+
{
|
23
|
+
static int timeHour = -1;
|
24
|
+
if(Hour() == timeHour) return;
|
25
|
+
timeHour = Hour();
|
26
|
+
|
27
|
+
string cookie=NULL,headers;
|
28
|
+
char post[],result[];
|
29
|
+
int res;
|
30
|
+
//--- to enable access to the server, you should add URL
|
31
|
+
//--- in the list of allowed URLs (Main Menu->Tools->Options, tab "Expert Advisors"):
|
32
|
+
string url="https://fx.minkabu.jp/references/holidays";
|
33
|
+
//--- Reset the last error code
|
34
|
+
ResetLastError();
|
35
|
+
//--- Loading a html page
|
36
|
+
int timeout=5000; //--- Timeout below 1000 (1 sec.) is not enough for slow Internet connection
|
37
|
+
res=WebRequest("GET",url,cookie,NULL,timeout,post,0,result,headers);
|
38
|
+
//--- Checking errors
|
39
|
+
if(res==-1)
|
40
|
+
{
|
41
|
+
Print("Error in WebRequest. Error code =",GetLastError());
|
42
|
+
//--- Perhaps the URL is not listed, display a message about the necessity to add the address
|
43
|
+
MessageBox("Add the address '"+url+"' in the list of allowed URLs on tab 'Expert Advisors'","Error",MB_ICONINFORMATION);
|
44
|
+
}
|
45
|
+
else
|
46
|
+
{
|
47
|
+
//--- Load successfully
|
48
|
+
PrintFormat("The file has been successfully loaded, File size =%d bytes.",ArraySize(result));
|
49
|
+
|
10
50
|
string text = CharArrayToString(result,0,WHOLE_ARRAY,CP_UTF8);
|
11
51
|
string str = NULL;
|
12
|
-
|
52
|
+
|
13
53
|
for(int i = 0; i < StringLen(fs-s fc-sub w25); i++){
|
14
54
|
if(StringSubstr(text, i + 7, 5) == "\"time\">"){
|
15
55
|
//曜日の取得に変更したい
|
16
56
|
string strTime = StringSubstr(text, i + 7, 5);
|
17
|
-
|
57
|
+
|
18
58
|
//国名の取得に変更したい
|
19
59
|
int posStar0 = StringFind(text, "★", i);
|
20
60
|
int posStar1 = StringFind(text, "</span>", posStar0);
|
21
61
|
string strStar = StringSubstr(text, posStar0, posStar1 - posStar0);
|
22
|
-
|
62
|
+
|
23
63
|
//イベントの取得に変更したい
|
24
64
|
int posEvent0 = StringFind(text, "]</span>", i) + 8;
|
25
65
|
int posEvent1 = StringFind(text, "</dt>", posEvent0);
|
26
66
|
string strEvent = StringSubstr(text, posEvent0, posEvent1 - posEvent0);
|
27
|
-
|
67
|
+
|
28
|
-
str += strTime + " " + strStar + " " + strEvent + "\n";
|
68
|
+
str += strTime + " " + strStar + " " + strEvent + "\n";
|
29
69
|
}
|
30
70
|
}
|
31
71
|
Comment(str);
|
32
|
-
}
|
72
|
+
}
|
73
|
+
}
|
33
74
|
```
|