Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string ThrLink = "http://2ch.pm/b/res/" + PostNum + ".html";
- string Res = @"/b/src/"+ PostNum + @"/";
- //Качаю тред в html
- string code, link;
- System.Net.WebRequest reqGET = System.Net.WebRequest.Create(ThrLink);
- System.Net.WebResponse resp = reqGET.GetResponse();
- System.IO.Stream stream = resp.GetResponseStream();
- System.IO.StreamReader sr = new System.IO.StreamReader(stream, Encoding.Default);
- code = sr.ReadToEnd();
- //Сохраняю как txt чтобы...
- System.IO.File.WriteAllText(@"html.txt", code);
- //...прочитать как массив строк
- String[] lines = System.IO.File.ReadAllLines(@"html.txt");
- //Считаю количество строк, содержащих ссылку на webm
- int i, ii=1;
- for (i=0; i<lines.Length; i++)
- {
- if (lines[i].Contains(Res))
- {
- link = Regex.Match(lines[i], Res + @"(.*).webm").Groups[0].Value;
- if (link.Contains(".webm"))
- {
- ii++;
- }
- }
- }
- //Создаю массив строк, количество элементов в котором равно количеству строк, содержащих Res + @"(.*).webm (номера вебмок)
- String[] Links = new String[ii];
- //Еще раз ищу те же строки и заношу в массив ссылок
- ii = 1;
- for (i = 0; i < lines.Length; i++)
- {
- if (lines[i].Contains(Res))
- {
- link = Regex.Match(lines[i], Res + @"(.*).webm").Groups[0].Value;
- if (link.Contains(".webm"))
- {
- Links[ii] = link;
- ii++;
- }
- }
- }
- //возвращаю номера вебмок
- return Links;
Advertisement
Add Comment
Please, Sign In to add comment