Домой Internet Build the DownloadString: Справочник по C#

Build the DownloadString: Справочник по C#

654
0


using System;
using System.IO;
using System.Net;
using System.Text.RegularExpressions;

class MainClass {
private static void Main() {
string remoteUri = "http://www.apress.com";
WebClient client = new WebClient();
string str = client.DownloadString(remoteUri);
MatchCollection matches = Regex.Matches(str, @"httpS+[^-,;:?].gif");
foreach (Match match in matches) {
foreach (Group grp in match.Groups) {
string file = grp.Value.Substring(grp.Value.LastIndexOf('/') + 1);
try {
Console.WriteLine("Downloading {0} to file {1}", grp.Value, file);
client.DownloadFile(new Uri(grp.Value), file);
} catch {
Console.WriteLine("Failed to download {0}", grp.Value);
}
}
}
}
}

Взято с http://www.java2s.com/Code/CSharp/Network/BuildtheDownloadString.htm

Build the DownloadString: Справочник по C#

0.00 (0%) 0 votes

ЧИТАТЬ ТАКЖЕ:  Отправка смс через сервис Smsified.com: Справочник по C#

ОСТАВЬТЕ ОТВЕТ

Пожалуйста, введите ваш комментарий!
пожалуйста, введите ваше имя здесь