Guest User

Untitled

a guest
Aug 16th, 2015
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         string ThrLink = "http://2ch.pm/b/res/" + PostNum + ".html";
  2.             string Res = @"/b/src/"+ PostNum + @"/";
  3.  
  4. //Качаю тред в html
  5.             string code, link;
  6.             System.Net.WebRequest reqGET = System.Net.WebRequest.Create(ThrLink);
  7.             System.Net.WebResponse resp = reqGET.GetResponse();
  8.             System.IO.Stream stream = resp.GetResponseStream();
  9.             System.IO.StreamReader sr = new System.IO.StreamReader(stream, Encoding.Default);
  10.             code = sr.ReadToEnd();
  11. //Сохраняю как txt чтобы...
  12.             System.IO.File.WriteAllText(@"html.txt", code);
  13. //...прочитать как массив строк
  14.             String[] lines = System.IO.File.ReadAllLines(@"html.txt");
  15.  
  16. //Считаю количество строк, содержащих ссылку на webm
  17.             int i, ii=1;
  18.             for (i=0; i<lines.Length; i++)
  19.             {
  20.                 if (lines[i].Contains(Res))
  21.                 {
  22.                     link = Regex.Match(lines[i], Res + @"(.*).webm").Groups[0].Value;
  23.                     if (link.Contains(".webm"))
  24.                     {
  25.                         ii++;
  26.                     }
  27.                 }
  28.             }
  29.  
  30. //Создаю массив строк, количество элементов в котором равно количеству строк, содержащих Res + @"(.*).webm (номера вебмок)
  31.             String[] Links = new String[ii];
  32. //Еще раз ищу те же строки и заношу в массив ссылок
  33.             ii = 1;
  34.             for (i = 0; i < lines.Length; i++)
  35.             {
  36.                 if (lines[i].Contains(Res))
  37.                 {
  38.                     link = Regex.Match(lines[i], Res + @"(.*).webm").Groups[0].Value;
  39.                     if (link.Contains(".webm"))
  40.                     {
  41.                         Links[ii] = link;
  42.                         ii++;
  43.                     }
  44.                 }
  45.             }
  46. //возвращаю номера вебмок
  47.             return Links;
  48.  
  49. Вывод:
  50. /b/src/99943716/14397195248010.webm">14397195248010.webm
  51. /b/src/99943716/14397195248010.webm" target="_blank" name="expandfunc" onclick="return expand('99943716-b7369a3db42c41ec722cc95b1e5f1cf9','/b/src/99943716/14397195248010.webm
  52. /b/src/99943716/14397195249101.webm">14397195249101.webm
  53. /b/src/99943716/14397195249101.webm" target="_blank" name="expandfunc" onclick="return expand('99943716-ac167a06ea0dca63bc5dfdb27d942346','/b/src/99943716/14397195249101.webm
  54. И т.д.
  55.  
  56. Мне нужно:
  57. 14397195248010
  58. 14397195248010
  59. 14397195249101
  60. 14397195249101
Advertisement
Add Comment
Please, Sign In to add comment