如何使用regex c#?验证dailymotion视频网址。
答案 0 :(得分:0)
有一篇来自作者的帖子" blatt"在互联网博客上关于它: http://cerjam.net/showthread.php?t=14410 我只是复制下面的代码
public enum dailyQuality
{
ld, sd, hd, hd720
}
public string dailyDownload(string code, dailyQuality quality)
{
WebClient aclient = new WebClient();
string pgdata = aclient.DownloadString("http://www.dailymotion.com/video/" + code);
string video = null;
switch (quality)
{
case dailyQuality.ld:
video = Regex.Split(pgdata, "ldURL%22%3A%22")[1];
break;
case dailyQuality.sd:
video = Regex.Split(pgdata, "sdURL%22%3A%22")[1];
break;
case dailyQuality.hd:
video = Regex.Split(pgdata, "hdURL%22%3A%22")[1];
break;
case dailyQuality.hd720:
video = Regex.Split(pgdata, "hd720URL%22%3A%22")[1];
break;
default:
return "...";
}
video = Regex.Split(video, "%22%2C%22")[0];
return makeNormalDaily(video);
}
private string makeNormalDaily(string data)
{
string astring = data.Replace("%3A", ":");
astring = astring.Replace("%5C%2F", "/");
astring = astring.Replace("%3F", "?");
astring = astring.Replace("%3D", "=");
return astring;
}