回答編集履歴
12
修正
test
CHANGED
@@ -136,7 +136,7 @@
|
|
136
136
|
|
137
137
|
|
138
138
|
|
139
|
-
第三者に改変される恐れ
|
139
|
+
第三者に改変される恐れがあるので万が一にそなえてこちらにも返信以下のコードを書いておきます。
|
140
140
|
|
141
141
|
```C#
|
142
142
|
|
11
修正
test
CHANGED
@@ -136,8 +136,180 @@
|
|
136
136
|
|
137
137
|
|
138
138
|
|
139
|
-
|
139
|
+
第三者に改変される恐れもあるのでこちらにも返信以下のコードを書いておきます。
|
140
|
+
|
140
|
-
|
141
|
+
```C#
|
142
|
+
|
141
|
-
|
143
|
+
using System;
|
144
|
+
|
142
|
-
|
145
|
+
using System.Collections.Generic;
|
146
|
+
|
143
|
-
|
147
|
+
using System.Linq;
|
148
|
+
|
149
|
+
using System.Text.RegularExpressions;
|
150
|
+
|
151
|
+
using System.Net;
|
152
|
+
|
153
|
+
using System.Threading;
|
154
|
+
|
155
|
+
using Newtonsoft.Json;
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
namespace Crawltest2
|
162
|
+
|
163
|
+
{
|
164
|
+
|
165
|
+
class Program
|
166
|
+
|
167
|
+
{
|
168
|
+
|
169
|
+
class Data
|
170
|
+
|
171
|
+
{
|
172
|
+
|
173
|
+
public string Category { get; set; }
|
174
|
+
|
175
|
+
public string Title { get; set; }
|
176
|
+
|
177
|
+
public string Date { get; set; }
|
178
|
+
|
179
|
+
public string Text { get; set; }
|
180
|
+
|
181
|
+
}
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
static List<string> Get_Data(string source, Regex re, string group)
|
186
|
+
|
187
|
+
{
|
188
|
+
|
189
|
+
List<string> tmp = new List<string>();
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
Match get_data = re.Match(source);
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
while (get_data.Success)
|
198
|
+
|
199
|
+
{
|
200
|
+
|
201
|
+
tmp.Add(get_data.Groups[group].Value);
|
202
|
+
|
203
|
+
get_data = get_data.NextMatch();
|
204
|
+
|
205
|
+
}
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
return tmp;
|
210
|
+
|
211
|
+
}
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
static void Main(string[] args)
|
216
|
+
|
217
|
+
{
|
218
|
+
|
219
|
+
WebClient wc = new WebClient();
|
220
|
+
|
221
|
+
wc.Encoding = System.Text.Encoding.UTF8;
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
List<Data> for_show = new List<Data>();
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
for (int i = 1; i < 6; i++)
|
230
|
+
|
231
|
+
{
|
232
|
+
|
233
|
+
string url = xxxxxxx{i};
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
string html = wc.DownloadString(url);
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
List<string> tmp_categorys = Get_Data(html, new Regex(@"<li class=""category"" style="".*?"">(?<category>.*?)</li>"), "category");
|
242
|
+
|
243
|
+
List<string> tmp_titles = Get_Data(html, new Regex(@"<li class=""title""><a href="".*?"">(?<title>.*?)</a></li>"), "title");
|
244
|
+
|
245
|
+
List<string> tmp_date = Get_Data(html, new Regex(@"<li class=""date"">(?<date>.*?)</li>"), "date");
|
246
|
+
|
247
|
+
List<string> tmp_text = Get_Data(html, new Regex(@"<li class=""description(|Single)"">(?<text>.*?)<"), "text");
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
tmp_text.RemoveAt(0);
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
for (int n = 0; n < tmp_categorys.Count; n++)
|
256
|
+
|
257
|
+
{
|
258
|
+
|
259
|
+
Data tmp_data = new Data
|
260
|
+
|
261
|
+
{
|
262
|
+
|
263
|
+
Category = tmp_categorys[n],
|
264
|
+
|
265
|
+
Title = tmp_titles[n],
|
266
|
+
|
267
|
+
Date = tmp_date[n],
|
268
|
+
|
269
|
+
Text = tmp_text[n]
|
270
|
+
|
271
|
+
};
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
for_show.Add(tmp_data);
|
276
|
+
|
277
|
+
}
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
// System.Threading.Thread.Sleep(4000);
|
282
|
+
|
283
|
+
}
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
var for_showSort = for_show.OrderBy(o => o.Category).ThenByDescending(o => o.Date);
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
string jsonstring = JsonConvert.SerializeObject(for_showSort, Formatting.Indented);
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
System.IO.StreamWriter sw = new System.IO.StreamWriter("test.txt", false, System.Text.Encoding.GetEncoding("shift_jis"));
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
sw.WriteLine(jsonstring);
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
sw.Close();
|
304
|
+
|
305
|
+
}
|
306
|
+
|
307
|
+
}
|
308
|
+
|
309
|
+
}
|
310
|
+
|
311
|
+
```
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
|
10
修正
test
CHANGED
@@ -124,6 +124,20 @@
|
|
124
124
|
|
125
125
|
|
126
126
|
|
127
|
+
#追記 2017/06/11
|
128
|
+
|
129
|
+
この質問はとあるサイトからソースコードを取得し、そこから正規表現で
|
130
|
+
|
131
|
+
特定の情報を抜き出すという内容のものでした。
|
132
|
+
|
133
|
+
この質問は2017年6月11日に解決され、質問者の方針により質問と
|
134
|
+
|
135
|
+
質問を解決したこの回答の内容が改変されました。
|
127
136
|
|
128
137
|
|
129
138
|
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
|
9
修正
test
CHANGED
@@ -126,252 +126,4 @@
|
|
126
126
|
|
127
127
|
|
128
128
|
|
129
|
-
# 補足
|
130
129
|
|
131
|
-
対象のサイトを確認しました。
|
132
|
-
|
133
|
-
1ページごとにurlの末尾の数字が変化しているだけ
|
134
|
-
|
135
|
-
のようなのでforを使って数字を増やしながら処理を繰り返せば
|
136
|
-
|
137
|
-
大丈夫だと思います。
|
138
|
-
|
139
|
-
```
|
140
|
-
|
141
|
-
https://www.cityheaven.net/k/new_community/osaka_umeda/ADNTenchoChokusoList/?start=1
|
142
|
-
|
143
|
-
```
|
144
|
-
|
145
|
-
正規表現によるデータの抽出も特に問題はないかと。
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
正規表現はこんな感じで。
|
150
|
-
|
151
|
-
```C#
|
152
|
-
|
153
|
-
using System;
|
154
|
-
|
155
|
-
using System.Text.RegularExpressions;
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
namespace regextest1
|
160
|
-
|
161
|
-
{
|
162
|
-
|
163
|
-
class Program
|
164
|
-
|
165
|
-
{
|
166
|
-
|
167
|
-
static void Main(string[] args)
|
168
|
-
|
169
|
-
{
|
170
|
-
|
171
|
-
string str1 = @"<li class=""category"" style=""color:#ffffff; background-color:#cab4d8; border-color:#aa91b9;"">イベント割引</li>";
|
172
|
-
|
173
|
-
string str2 = @"<li class=""title""><a href="" / k / umeda_hybrid / A6TenchoChokusoList / "">【ご新規様限定】100分コース以上5000円…</a></li>";
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
Regex r1 = new Regex(@"<li class=""category"".*?>(?<category>.+?)<\/li>");
|
178
|
-
|
179
|
-
Regex r2 = new Regex(@"<li class=""title""><a href=.*?>(?<title>.*?)</a></li>");
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
var m1 = r1.Match(str1);
|
184
|
-
|
185
|
-
var m2 = r2.Match(str2);
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
Console.WriteLine(m1.Groups["category"].Value);
|
190
|
-
|
191
|
-
Console.WriteLine(m2.Groups["title"].Value);
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
Console.ReadKey();
|
196
|
-
|
197
|
-
}
|
198
|
-
|
199
|
-
}
|
200
|
-
|
201
|
-
}
|
202
|
-
|
203
|
-
```
|
204
|
-
|
205
|
-
#補足2
|
206
|
-
|
207
|
-
完成させました。このプログラムが正確に動くかどうかは分かりません。
|
208
|
-
|
209
|
-
```C#
|
210
|
-
|
211
|
-
using System;
|
212
|
-
|
213
|
-
using System.Collections.Generic;
|
214
|
-
|
215
|
-
using System.Linq;
|
216
|
-
|
217
|
-
using System.Text.RegularExpressions;
|
218
|
-
|
219
|
-
using System.Net;
|
220
|
-
|
221
|
-
using System.Threading;
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
namespace Crawltest2
|
226
|
-
|
227
|
-
{
|
228
|
-
|
229
|
-
class Program
|
230
|
-
|
231
|
-
{
|
232
|
-
|
233
|
-
class Data
|
234
|
-
|
235
|
-
{
|
236
|
-
|
237
|
-
public string Category { get; set; }
|
238
|
-
|
239
|
-
public string Title { get; set; }
|
240
|
-
|
241
|
-
}
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
static void Main(string[] args)
|
246
|
-
|
247
|
-
{
|
248
|
-
|
249
|
-
WebClient wc = new WebClient();
|
250
|
-
|
251
|
-
wc.Encoding = System.Text.Encoding.UTF8;
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
List<Data> for_show = new List<Data>();
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
for(int i = 1; i < 6; i++)
|
260
|
-
|
261
|
-
{
|
262
|
-
|
263
|
-
string url = $"https://www.cityheaven.net/k/new_community/osaka_umeda/ADNTenchoChokusoList/?start={i}";
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
string html = wc.DownloadString(url);
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
List<string> tmp_categorys = new List<string>();
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
Regex rc = new Regex(@"<li class=""category"" style="".*?"">(?<category>.*?)</li>");
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
Match get_category = rc.Match(html);
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
while (get_category.Success)
|
284
|
-
|
285
|
-
{
|
286
|
-
|
287
|
-
tmp_categorys.Add(get_category.Groups["category"].Value);
|
288
|
-
|
289
|
-
get_category = get_category.NextMatch();
|
290
|
-
|
291
|
-
}
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
List<string> tmp_titles = new List<string>();
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
Regex rt = new Regex(@"<li class=""title""><a href="".*?"">(?<title>.*?)</a></li>");
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
Match get_title = rt.Match(html);
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
while (get_title.Success)
|
308
|
-
|
309
|
-
{
|
310
|
-
|
311
|
-
tmp_titles.Add(get_title.Groups["title"].Value);
|
312
|
-
|
313
|
-
get_title = get_title.NextMatch();
|
314
|
-
|
315
|
-
}
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
for(int n = 0; n < tmp_categorys.Count; n++)
|
320
|
-
|
321
|
-
{
|
322
|
-
|
323
|
-
Data tmp_data = new Data
|
324
|
-
|
325
|
-
{
|
326
|
-
|
327
|
-
Category = tmp_categorys[n],
|
328
|
-
|
329
|
-
Title = tmp_titles[n]
|
330
|
-
|
331
|
-
};
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
for_show.Add(tmp_data);
|
336
|
-
|
337
|
-
}
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
System.Threading.Thread.Sleep(4000);
|
342
|
-
|
343
|
-
}
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
var for_showSort = for_show.OrderBy(o => o.Category).ThenBy(o => o.Title);
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
foreach(var ans in for_showSort)
|
352
|
-
|
353
|
-
{
|
354
|
-
|
355
|
-
Console.WriteLine($"{ans.Category}:{ans.Title}");
|
356
|
-
|
357
|
-
}
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
Console.ReadKey();
|
362
|
-
|
363
|
-
}
|
364
|
-
|
365
|
-
}
|
366
|
-
|
367
|
-
}
|
368
|
-
|
369
|
-
```
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
8
修正
test
CHANGED
@@ -214,14 +214,12 @@
|
|
214
214
|
|
215
215
|
using System.Linq;
|
216
216
|
|
217
|
-
using System.Text;
|
218
|
-
|
219
|
-
using System.Threading.Tasks;
|
220
|
-
|
221
217
|
using System.Text.RegularExpressions;
|
222
218
|
|
223
219
|
using System.Net;
|
224
220
|
|
221
|
+
using System.Threading;
|
222
|
+
|
225
223
|
|
226
224
|
|
227
225
|
namespace Crawltest2
|
@@ -338,6 +336,10 @@
|
|
338
336
|
|
339
337
|
}
|
340
338
|
|
339
|
+
|
340
|
+
|
341
|
+
System.Threading.Thread.Sleep(4000);
|
342
|
+
|
341
343
|
}
|
342
344
|
|
343
345
|
|
7
修正
test
CHANGED
@@ -202,8 +202,174 @@
|
|
202
202
|
|
203
203
|
```
|
204
204
|
|
205
|
-
|
205
|
+
#補足2
|
206
|
+
|
206
|
-
|
207
|
+
完成させました。このプログラムが正確に動くかどうかは分かりません。
|
208
|
+
|
207
|
-
|
209
|
+
```C#
|
210
|
+
|
208
|
-
|
211
|
+
using System;
|
212
|
+
|
209
|
-
|
213
|
+
using System.Collections.Generic;
|
214
|
+
|
215
|
+
using System.Linq;
|
216
|
+
|
217
|
+
using System.Text;
|
218
|
+
|
219
|
+
using System.Threading.Tasks;
|
220
|
+
|
221
|
+
using System.Text.RegularExpressions;
|
222
|
+
|
223
|
+
using System.Net;
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
namespace Crawltest2
|
228
|
+
|
229
|
+
{
|
230
|
+
|
231
|
+
class Program
|
232
|
+
|
233
|
+
{
|
234
|
+
|
235
|
+
class Data
|
236
|
+
|
237
|
+
{
|
238
|
+
|
239
|
+
public string Category { get; set; }
|
240
|
+
|
241
|
+
public string Title { get; set; }
|
242
|
+
|
243
|
+
}
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
static void Main(string[] args)
|
248
|
+
|
249
|
+
{
|
250
|
+
|
251
|
+
WebClient wc = new WebClient();
|
252
|
+
|
253
|
+
wc.Encoding = System.Text.Encoding.UTF8;
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
List<Data> for_show = new List<Data>();
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
for(int i = 1; i < 6; i++)
|
262
|
+
|
263
|
+
{
|
264
|
+
|
265
|
+
string url = $"https://www.cityheaven.net/k/new_community/osaka_umeda/ADNTenchoChokusoList/?start={i}";
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
string html = wc.DownloadString(url);
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
List<string> tmp_categorys = new List<string>();
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
Regex rc = new Regex(@"<li class=""category"" style="".*?"">(?<category>.*?)</li>");
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
Match get_category = rc.Match(html);
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
while (get_category.Success)
|
286
|
+
|
287
|
+
{
|
288
|
+
|
289
|
+
tmp_categorys.Add(get_category.Groups["category"].Value);
|
290
|
+
|
291
|
+
get_category = get_category.NextMatch();
|
292
|
+
|
293
|
+
}
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
List<string> tmp_titles = new List<string>();
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
Regex rt = new Regex(@"<li class=""title""><a href="".*?"">(?<title>.*?)</a></li>");
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
Match get_title = rt.Match(html);
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
while (get_title.Success)
|
310
|
+
|
311
|
+
{
|
312
|
+
|
313
|
+
tmp_titles.Add(get_title.Groups["title"].Value);
|
314
|
+
|
315
|
+
get_title = get_title.NextMatch();
|
316
|
+
|
317
|
+
}
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
for(int n = 0; n < tmp_categorys.Count; n++)
|
322
|
+
|
323
|
+
{
|
324
|
+
|
325
|
+
Data tmp_data = new Data
|
326
|
+
|
327
|
+
{
|
328
|
+
|
329
|
+
Category = tmp_categorys[n],
|
330
|
+
|
331
|
+
Title = tmp_titles[n]
|
332
|
+
|
333
|
+
};
|
334
|
+
|
335
|
+
|
336
|
+
|
337
|
+
for_show.Add(tmp_data);
|
338
|
+
|
339
|
+
}
|
340
|
+
|
341
|
+
}
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
var for_showSort = for_show.OrderBy(o => o.Category).ThenBy(o => o.Title);
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
foreach(var ans in for_showSort)
|
350
|
+
|
351
|
+
{
|
352
|
+
|
353
|
+
Console.WriteLine($"{ans.Category}:{ans.Title}");
|
354
|
+
|
355
|
+
}
|
356
|
+
|
357
|
+
|
358
|
+
|
359
|
+
Console.ReadKey();
|
360
|
+
|
361
|
+
}
|
362
|
+
|
363
|
+
}
|
364
|
+
|
365
|
+
}
|
366
|
+
|
367
|
+
```
|
368
|
+
|
369
|
+
|
370
|
+
|
371
|
+
|
372
|
+
|
373
|
+
|
374
|
+
|
375
|
+
|
6
修正
test
CHANGED
@@ -130,9 +130,11 @@
|
|
130
130
|
|
131
131
|
対象のサイトを確認しました。
|
132
132
|
|
133
|
-
url
|
133
|
+
1ページごとにurlの末尾の数字が変化しているだけ
|
134
|
-
|
134
|
+
|
135
|
-
数字を増やしながら処理を繰り返せば
|
135
|
+
のようなのでforを使って数字を増やしながら処理を繰り返せば
|
136
|
+
|
137
|
+
大丈夫だと思います。
|
136
138
|
|
137
139
|
```
|
138
140
|
|
5
修正
test
CHANGED
@@ -121,3 +121,87 @@
|
|
121
121
|
teratailを対象に考えています。
|
122
122
|
|
123
123
|
アルファベットと番号順になると思います。
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
# 補足
|
130
|
+
|
131
|
+
対象のサイトを確認しました。
|
132
|
+
|
133
|
+
urlは末尾の数字が1つずつ増えているようなのでforを使って
|
134
|
+
|
135
|
+
数字を増やしながら処理を繰り返せば大丈夫だと思います。
|
136
|
+
|
137
|
+
```
|
138
|
+
|
139
|
+
https://www.cityheaven.net/k/new_community/osaka_umeda/ADNTenchoChokusoList/?start=1
|
140
|
+
|
141
|
+
```
|
142
|
+
|
143
|
+
正規表現によるデータの抽出も特に問題はないかと。
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
正規表現はこんな感じで。
|
148
|
+
|
149
|
+
```C#
|
150
|
+
|
151
|
+
using System;
|
152
|
+
|
153
|
+
using System.Text.RegularExpressions;
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
namespace regextest1
|
158
|
+
|
159
|
+
{
|
160
|
+
|
161
|
+
class Program
|
162
|
+
|
163
|
+
{
|
164
|
+
|
165
|
+
static void Main(string[] args)
|
166
|
+
|
167
|
+
{
|
168
|
+
|
169
|
+
string str1 = @"<li class=""category"" style=""color:#ffffff; background-color:#cab4d8; border-color:#aa91b9;"">イベント割引</li>";
|
170
|
+
|
171
|
+
string str2 = @"<li class=""title""><a href="" / k / umeda_hybrid / A6TenchoChokusoList / "">【ご新規様限定】100分コース以上5000円…</a></li>";
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
Regex r1 = new Regex(@"<li class=""category"".*?>(?<category>.+?)<\/li>");
|
176
|
+
|
177
|
+
Regex r2 = new Regex(@"<li class=""title""><a href=.*?>(?<title>.*?)</a></li>");
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
var m1 = r1.Match(str1);
|
182
|
+
|
183
|
+
var m2 = r2.Match(str2);
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
Console.WriteLine(m1.Groups["category"].Value);
|
188
|
+
|
189
|
+
Console.WriteLine(m2.Groups["title"].Value);
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
Console.ReadKey();
|
194
|
+
|
195
|
+
}
|
196
|
+
|
197
|
+
}
|
198
|
+
|
199
|
+
}
|
200
|
+
|
201
|
+
```
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
|
4
修正
test
CHANGED
@@ -120,4 +120,4 @@
|
|
120
120
|
|
121
121
|
teratailを対象に考えています。
|
122
122
|
|
123
|
-
アルファベットと番号順
|
123
|
+
アルファベットと番号順になると思います。
|
3
修正
test
CHANGED
@@ -32,7 +32,7 @@
|
|
32
32
|
|
33
33
|
public string Title { get; set; }
|
34
34
|
|
35
|
-
public
|
35
|
+
public int Number { get; set; }
|
36
36
|
|
37
37
|
}
|
38
38
|
|
@@ -74,7 +74,7 @@
|
|
74
74
|
|
75
75
|
Title = m.Groups["title"].Value,
|
76
76
|
|
77
|
-
Number = m.Groups["num"].Value
|
77
|
+
Number = int.Parse(m.Groups["num"].Value)
|
78
78
|
|
79
79
|
};
|
80
80
|
|
@@ -90,27 +90,15 @@
|
|
90
90
|
|
91
91
|
|
92
92
|
|
93
|
-
var questionSort = list.
|
93
|
+
var questionSort = list.OrderBy(o => o.Category).ThenBy(o => o.Number);
|
94
94
|
|
95
95
|
|
96
96
|
|
97
|
-
foreach(var
|
97
|
+
foreach (var q in questionSort)
|
98
98
|
|
99
99
|
{
|
100
100
|
|
101
|
-
foreach(var q in list)
|
102
|
-
|
103
|
-
{
|
104
|
-
|
105
|
-
if(q.Category == item.Key)
|
106
|
-
|
107
|
-
{
|
108
|
-
|
109
|
-
|
101
|
+
Console.WriteLine($"{q.Category}:{q.Title}:{q.Number}");
|
110
|
-
|
111
|
-
}
|
112
|
-
|
113
|
-
}
|
114
102
|
|
115
103
|
}
|
116
104
|
|
@@ -132,8 +120,4 @@
|
|
132
120
|
|
133
121
|
teratailを対象に考えています。
|
134
122
|
|
135
|
-
アルファベット順です。
|
123
|
+
アルファベットと番号順です。
|
136
|
-
|
137
|
-
(アルファベットとNumberでソートをするのに失敗したため)
|
138
|
-
|
139
|
-
|
2
修正
test
CHANGED
@@ -133,3 +133,7 @@
|
|
133
133
|
teratailを対象に考えています。
|
134
134
|
|
135
135
|
アルファベット順です。
|
136
|
+
|
137
|
+
(アルファベットとNumberでソートをするのに失敗したため)
|
138
|
+
|
139
|
+
|
1
修正
test
CHANGED
@@ -52,7 +52,7 @@
|
|
52
52
|
|
53
53
|
|
54
54
|
|
55
|
-
for (int i = 0; i <
|
55
|
+
for (int i = 0; i < 40; i++)
|
56
56
|
|
57
57
|
{
|
58
58
|
|
@@ -84,17 +84,13 @@
|
|
84
84
|
|
85
85
|
|
86
86
|
|
87
|
-
|
87
|
+
Thread.Sleep(4000);
|
88
88
|
|
89
89
|
}
|
90
90
|
|
91
91
|
|
92
92
|
|
93
|
-
var questionSort = list.GroupBy(g => g.Category)
|
93
|
+
var questionSort = list.GroupBy(g => g.Category).OrderBy(g => g.Key);
|
94
|
-
|
95
|
-
.Select(g => new { Category = g.Key, Count = g.Count() })
|
96
|
-
|
97
|
-
.OrderBy(g => g.Category).ThenBy(g => g.Count);
|
98
94
|
|
99
95
|
|
100
96
|
|
@@ -106,7 +102,7 @@
|
|
106
102
|
|
107
103
|
{
|
108
104
|
|
109
|
-
if(q.Category == item.
|
105
|
+
if(q.Category == item.Key)
|
110
106
|
|
111
107
|
{
|
112
108
|
|
@@ -136,4 +132,4 @@
|
|
136
132
|
|
137
133
|
teratailを対象に考えています。
|
138
134
|
|
139
|
-
|
135
|
+
アルファベット順です。
|