fork download
  1. using System;
  2. using System.IO;
  3. using System.Net;
  4. using System.Text;
  5.  
  6. public class WebClientGet2
  7. {
  8. static void Main()
  9. {
  10. string[,] b = new string[60, 5];
  11. int gyou = 0;
  12. int kopisurukazu = 0;
  13. WebClient wc = new WebClient();
  14. using (StreamReader r = new StreamReader(@"C:\Users\ハンバーガー\Desktop\糞\メモ\コピペ\copipe.txt"))
  15. {
  16. string line;
  17. while ((line = r.ReadLine()) != null) // 1行ずつ読み出し。
  18. {
  19. b[kopisurukazu, gyou] = line;
  20. Console.WriteLine(b[kopisurukazu, gyou]);
  21. gyou++;
  22. if (gyou == 5)
  23. {
  24. kopisurukazu++;
  25. gyou = 0;
  26. }
  27. }
  28. Console.ReadLine();
  29. }
  30. int count2 = 0;
  31. string file = @"C:\Users\ハンバーガー\Desktop\糞\メモ\コピペ\";
  32. string[] urllist = new string[60];
  33. string[] urllist2 = new string[60];
  34. string[] title = new string[60];
  35. while (count2<kopisurukazu)
  36. {
  37. Stream rssst = wc.OpenRead(b[count2, 0]);
  38.  
  39. Encoding rssenc = Encoding.GetEncoding("UTF-8");
  40. StreamReader rsssr = new StreamReader(rssst, rssenc);
  41. string rss = rsssr.ReadToEnd();
  42.  
  43. int rssichi = 0;
  44. int titlenoichi = 0;
  45. //string kijiurl = "";
  46. //string kijiurl2 = "";
  47. for (int count3 = 0; ; count3++)
  48. {
  49. //Stream urlst = wc.OpenRead(file + "kijinourl.txt");
  50.  
  51. rssichi = rss.IndexOf("<item rdf:about=", rssichi) + 17;
  52.  
  53. //"<item rdf:about="がなかったらループから抜ける
  54. if (rssichi == 16)
  55. {
  56. break;
  57. }
  58.  
  59. urllist[count3] = rss.Substring(rssichi, rss.IndexOf(">", rssichi) - rssichi - 1);
  60. title[count3] = rss.Substring(titlenoichi = rss.IndexOf("<title>", rssichi) + 7, rss.IndexOf("</title>", rssichi) - titlenoichi);
  61.  
  62. //記事のURLをファイルに書き込み
  63. //Encoding urlenc = Encoding.GetEncoding(b[count2, 4]);
  64. //StreamReader urlsr = new StreamReader(urlst, urlenc);
  65. //kijiurl2 = urlsr.ReadToEnd();
  66. //urlst.Close();
  67.  
  68. //using (StreamWriter w = new StreamWriter(file + "kijinourl.txt"))
  69. //{
  70. // w.WriteLine(kijiurl2 + kijiurl);
  71. //}
  72. }
  73. for (int count5 = 0; urllist2[count5] != null; count5++)
  74. {
  75. if (0 <= Array.IndexOf(urllist2, urllist[count5]))
  76. {
  77. Console.WriteLine("一致する要素が見つかりました");
  78. }
  79. else
  80. {
  81. Console.WriteLine("一致する要素が見つかりませんでした");
  82. Stream st = wc.OpenRead(urllist[count5]);
  83.  
  84. Encoding enc = Encoding.GetEncoding(b[count2, 4]);
  85. StreamReader sr = new StreamReader(st, enc);
  86. string html = sr.ReadToEnd();
  87. int a = html.Length;
  88. int honbunnohajimenoichi = html.IndexOf(b[count2, 1]) + b[count2, 1].Length;
  89. int tudukinohajimenoichi = html.IndexOf(b[count2, 2]);// - dat[count2, 2].Length;
  90. int owarinoichi = html.IndexOf(b[count2, 3]);
  91.  
  92. string honbun = html.Substring(honbunnohajimenoichi, tudukinohajimenoichi - honbunnohajimenoichi);
  93.  
  94. string tuduki = html.Substring(tudukinohajimenoichi, owarinoichi - tudukinohajimenoichi);
  95.  
  96. using (StreamWriter w = new StreamWriter(file + @"アフィ\" + title[count5] + "title.txt"))
  97. {
  98. w.WriteLine(title[count5]);
  99. }
  100. using (StreamWriter w = new StreamWriter(file + @"アフィ\" + title[count5] + "honbun.txt"))
  101. {
  102. w.WriteLine(honbun);
  103. }
  104. using (StreamWriter w = new StreamWriter(file + @"アフィ\" + title[count5] + "tuduki.txt"))
  105. {
  106. w.WriteLine(tuduki);
  107. }
  108. }
  109. }
  110. Console.ReadLine();
  111. urllist.CopyTo(urllist2, 0);
  112. for (int count4 = 0; urllist2[count4] != null; count4++)
  113. {
  114. Console.WriteLine(urllist2[count4]);
  115. //Console.ReadLine();
  116. }
  117. count2++;
  118. }
  119. }
  120. }
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
Runtime error #stdin #stdout 0.04s 41232KB
stdin
Standard input is empty
stdout
Standard output is empty