-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGetTheProgram.cs
More file actions
93 lines (76 loc) · 2.88 KB
/
GetTheProgram.cs
File metadata and controls
93 lines (76 loc) · 2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
using System;
using System.CodeDom;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using HtmlAgilityPack;
using System.Xml;
namespace InvictusCFCycles
{
internal class Program
{
public static void Main(string[] args)
{
//April 3 - august 8
//
var addressOfCF = String.Empty;
var pvm = 1;
var kknumber = 0;
var weeknumber = 1;
var actualMonthNro = 4;
string value = null;
int i = 1;
string[] kk = {"april", "may", "june", "july", "august", "september", "november", "october", "december"};
try
{
foreach (string item in kk)
{
for (i = 1; i <= System.DateTime.DaysInMonth(2017, actualMonthNro); i++)
{
addressOfCF = String.Format(@"http://www.crossfitinvictus.com/wod/{0}-{1}-2017-competition/",
kk[kknumber], pvm);
var wc = new HtmlWeb();
var doc = wc.Load(addressOfCF);
//var doc = GetCleanHtml(addressOfCF);
if (doc != null)
{
var node = doc.DocumentNode.SelectSingleNode("//div[@class='entry-content']");
if (node != null)
{
var noodde = node.InnerHtml;
value = value + "\n" + noodde.InnerText.Trim() + "=============================";
}
}
if (i % 7 == 0)
{
var nameOfFile =
"InvictusWeek" + weeknumber; //String.Format("Invictus{0}{1}.txt",kk[kknumber],pvm);
using (var sw = new StreamWriter(
(@"D:\Gdrive\CrossfitValmennus\Invictuksen ohjelma2017\" + nameOfFile),
true, Encoding.UTF8))
{
sw.Write(value);
}
value = String.Empty;
}
actualMonthNro++;
}
}
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
}
public static string GetCleanHtml(string html)
{
var doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(html);
return HtmlAgilityPack.HtmlEntity.DeEntitize(doc.DocumentNode.InnerText);
}
}
}