/// <summary> /// 取指定URL的视频资料 /// </summary> /// <param name="url">网址</param> /// <returns>分享视频实体</returns> public VideoInfo GetVideoInfo(string url) { #region 测试数据 //http://v.163.com/movie/2011/8/R/S/M7BN25K5V_M7BPHVERS.html //http://swf.ws.126.net/movieplayer/-0-2_M7BN25K5V_M7BPHVERS-vimg1_ws_126_net//image/snapshot_movie/2011/8/H/F/M7BPHVDHF-.swf //http://swf.ws.126.net/movieplayer/-0-2_M7BN25K5V_M7BPHVERS-.swf #endregion if (url.EndsWith(".swf")) { return(null); } string[] list = url.Split('/'); string code = list[list.Length - 1]; code = code.Left(code.Length - 5); string data = (Net2.GetRemoteHtmlCode4(url) ?? "").ReplaceRN(); string on = data.GetMatchingValues("<li class=\"on\"> <a class=\"picLink\"(.+?)<div class=\"nowplay\">正在播放...</div> </li>").FirstOrDefault() ?? ""; //Msg.WriteEnd(on); string title = (data.GetMatchingValues("<title>(.+?)</title>", "<title>", "</title>").FirstOrDefault() ?? "").Trim(); string img = on.GetMatchingValues("<img height=\"90\" width=\"120\" src=\"(.+?)\" />", "<img height=\"90\" width=\"120\" src=\"", "\" />").FirstOrDefault() ?? ""; string flv = "http://swf.ws.126.net/movieplayer/-0-2_{0}-.swf".FormatWith(code); if (title.IndexOf("_网易") != -1) { title = title.Left(title.IndexOf("_网易")).Trim().TrimEnd('_').Trim(); } return(new VideoInfo() { PicUrl = img, Title = title, Url = flv }); }
/// <summary> /// 取登录账号好友信息 /// </summary> /// <param name="accessToken">Access Token</param> /// <param name="accessSecret">Access Secret</param> /// <returns>取登录账号好友信息</returns> public IList <UserInfo> GetFriendsInfo(string accessToken, string accessSecret) { IList <UserInfo> list = new List <UserInfo>(); string data = Net2.GetRemoteHtmlCode4(friends_list + "?access_token=" + accessToken, Encoding.UTF8).ReplaceRN().Trim(); if (data.IsNullEmpty()) { return(list); } data = data.Substring(1, data.Length - 2); IList <string> userlist = data.GetMatchingValues("{(.+?)}", "{", "}"); foreach (string info in userlist) { UserInfo user = new UserInfo(); user.UserID = info.GetMatchingValues("\"user_id\": \"(.+?)\"", "\"user_id\": \"", "\"").FirstOrDefault() ?? ""; user.Name = info.GetMatchingValues("\"name\": \"(.+?)\"", "\"name\": \"", "\"").FirstOrDefault() ?? ""; user.Sex = (info.GetMatchingValues("\"gender\": \"(.+?)\"", "\"gender\": \"", "\"").FirstOrDefault() ?? "male") == "male" ? 1 : 0; bool is_friend = (info.GetMatchingValues("\"is_friend\": (.+?),", "\"is_friend\": ", ",").FirstOrDefault() ?? "false") == "true" ? true : false; user.Email = info.GetMatchingValues("\"email_hashes\": \\[ \"(.+?)\"", "\"email_hashes\": [ \"", "\"").FirstOrDefault() ?? ""; if (user.Name.IsEmail()) { user.Email = user.Name; user.Name = user.Name.Split('@')[0]; } if (is_friend) { list.Add(user); } } return(list); }
/// <summary> /// 取指定URL的视频资料 /// </summary> /// <param name="url">网址</param> /// <returns>分享视频实体</returns> public VideoInfo GetVideoInfo(string url) { #region 测试数据 //http://v.ifeng.com/include/exterior.swf?guid=d6dcd88a-78b5-4dca-9dbf-4e5504a1ee90&AutoPlay=false //http://v.ifeng.com/news/world/201110/d6dcd88a-78b5-4dca-9dbf-4e5504a1ee90.shtml //var videoinfo={"id":"d6dcd88a-78b5-4dca-9dbf-4e5504a1ee90","wapstatus":"0","name":"卡扎菲临终画面曝光 被抓头发可勉强站立","duration":"128","url":"http://v.ifeng.com/news/world/201110/d6dcd88a-78b5-4dca-9dbf-4e5504a1ee90.shtml","img":"http://img.ifeng.com/itvimg/2011/10/21/d0c833eb-5c5a-49d2-9e9d-1e83ae3b4551140.jpg"}; #endregion if (url.IndexOf(".swf?") != -1) { return(null); } string[] list = url.Split('/'); string code = list[list.Length - 1]; code = code.Left(code.Length - 6); string data = (Net2.GetRemoteHtmlCode4(url, Encoding.UTF8) ?? "").ReplaceRN(); string title = (data.GetMatchingValues("\"name\":\"(.+?)\"", "\"name\":\"", "\"").FirstOrDefault() ?? "").Trim(); string img = data.GetMatchingValues("\"img\":\"(.+?)\"", "\"img\":\"", "\"").FirstOrDefault() ?? ""; string flv = "http://v.ifeng.com/include/exterior.swf?guid={0}&AutoPlay=false".FormatWith(code); return(new VideoInfo() { PicUrl = img, Title = title, Url = flv }); }
/// <summary> /// 取指定URL的视频资料 /// </summary> /// <param name="url">网址</param> /// <returns>分享视频实体</returns> public VideoInfo GetVideoInfo(string url) { #region 测试数据 //http://v.ku6.com/show/FHC32qF5cQqwOcSA.html //http://service.weibo.com/share/share.php?c=spr_web_bd_ku6_weibo //&url=http%3A%2F%2Fv.ku6.com%2Fshow%2FFHC32qF5cQqwOcSA.html //&appkey=612700343 //&ralateUid=1829627032 //&title=%E6%95%91%E4%BA%BA%E9%98%BF%E5%A7%A8%E8%8E%B75%E4%B8%87%E5%85%83%E5%A5%96%E9%87%91%20%E8%A1%A8%E7%A4%BA%E6%8A%8A%E9%83%A8%E5%88%86%E5%A5%96%E9%87%91%E6%8D%90%E7%BB%99%E5%A5%B3%E7%AB%A5 //&source=%E9%85%B76%E7%BD%91 //&sourceUrl=http%3A%2F%2Fwww.ku6.com%2F //&content=gbk //&pic=http%3A%2F%2Fi3.ku6img.com%2Fencode%2Fpicpath%2F2011%2F10%2F18%2F9%2F1322073942415_8090181_8090181%2F5.jpg //title: "\u6551\u4eba\u963f\u59e8\u83b75\u4e07\u5143\u5956\u91d1\u0020\u8868\u793a\u628a\u90e8\u5206\u5956\u91d1\u6350\u7ed9\u5973\u7ae5" //cover: "http://i3.ku6img.com/encode/picpath/2011/10/18/9/1322073942415_8090181_8090181/5.jpg" //http://player.ku6.com/refer/FHC32qF5cQqwOcSA/v.swf #endregion if (url.EndsWith("/v.swf")) { string sid = url.GetMatchingValues("/refer/(.+?)/v.swf", "/refer/", "/v.swf").FirstOrDefault() ?? ""; if (sid.IsNullEmpty()) { return(null); } url = "http://v.ku6.com/show/{0}.html".FormatWith(sid); } string[] list = url.Split('/'); string code = list[list.Length - 1].GetMatchingValues("(.+?).html", " ", ".html").FirstOrDefault() ?? ""; if (code.IsNullEmpty()) { return(null); } string data = Net2.GetRemoteHtmlCode4(url, Encoding.UTF8) ?? ""; string title = (data.GetMatchingValues("title: \"(.+?)\"", "title: \"", "\"").FirstOrDefault() ?? ""); if (title.IsNullEmpty()) { title = (data.GetMatchingValues("title : \"(.+?)\"", "title: \"", "\"").FirstOrDefault() ?? ""); } title = title.Ascii2Native(); string img = data.GetMatchingValues("cover: \"(.+?)\"", "cover: \"", "\"").FirstOrDefault() ?? ""; if (img.IsNullEmpty()) { img = data.GetMatchingValues("cover : \"(.+?)\"", "cover : \"", "\"").FirstOrDefault() ?? ""; } string flv = "http://player.ku6.com/refer/{0}/v.swf".FormatWith(code); return(new VideoInfo() { PicUrl = img, Title = title, Url = flv }); }
/// <summary> /// 同步消息 /// </summary> /// <param name="accessToken">Access Token</param> /// <param name="accessSecret">Access Secret</param> /// <param name="text">消息</param> public void SendText(string accessToken, string accessSecret, string text) { List <UrlParameter> param = new List <UrlParameter>(); param.Add(new UrlParameter("access_token", accessToken)); param.Add(new UrlParameter("method", "post")); param.Add(new UrlParameter("message", text.SubString(270, "").UrlUpperEncode())); param.Sort(new UrlParameterCompre()); Net2.GetRemoteHtmlCode4(add + "?" + OAuthCommon.GetUrlParameter(param), Encoding.UTF8); }
/// <summary> /// 取指定URL的视频资料 /// </summary> /// <param name="url">网址</param> /// <returns>分享视频实体</returns> public VideoInfo GetVideoInfo(string url) { #region 测试数据 //http://www.tudou.com/playlist/p/l13328532i103653275.html //http://www.tudou.com/playlist/p/a67602i103588337.html //http://www.tudou.com/playlist/p/l13844631.html //http://www.tudou.com/playlist/p/a67554.html //http://www.tudou.com/playlist/p/a67615i106685029.html //http://www.tudou.com/programs/view/tQZEb2YCQ8M/ //http://www.tudou.com/programs/view/akg0GtypUC8/ //http://www.tudou.com/programs/view/T9Jg5KRoMKU/ //http://www.tudou.com/programs/view/ma3EfG-d3Ys/ //http://www.tudou.com/programs/view/DiZGd71W2Q4/ //http://i1.tdimg.com/106/450/394/p.jpg //http://www.tudou.com/v/DiZGd71W2Q4/v.swf //http://v.t.sina.com.cn/share/share.php?c=spr_web_bd_tudou_weibo //&url=http%3A%2F%2Fwww.tudou.com%2Fplaylist%2Fp%2Fl13328532i103653275.html //&title=%E3%80%8A%E3%80%8A%E9%85%B1%E8%82%98%E5%AD%90%E3%80%8B%E3%80%90%E5%8C%97%E4%BA%AC%E7%94%B5%E5%BD%B1%E5%AD%A6%E9%99%A2%E5%AF%BC%E6%BC%94%E7%B3%BB%E5%AD%A6%E7%94%9F%E4%BD%9C%E5%93%81%E3%80%91%E3%80%8B++%EF%BC%88%E5%8F%AF%E9%80%89%E5%8E%9F%E7%94%BB%E6%B8%85%E6%99%B0%E5%BA%A6%EF%BC%89 //&source=%E5%9C%9F%E8%B1%86%E7%BD%91 //&sourceUrl=http%3A%2F%2Fwww.tudou.com%2F //&content=gb2312 //&pic=http%3A%2F%2Fi2.tdimg.com%2F103%2F653%2F275%2Fp.jpg //&appkey=2043051649 //&ralateUid=1697524603 #endregion string apiUrl = "http://api.tudou.com/v3/gw?method=item.info.get&appKey=7ee7a34f14a4c74b&format=json&itemCodes={0}"; if (url.EndsWith("/v.swf")) { string sid = url.GetMatchingValues("/v/(.+?)/v.swf", "/v/", "/v.swf").FirstOrDefault() ?? ""; if (sid.IsNullEmpty()) { return(null); } url = "http://www.tudou.com/programs/view/{0}/".FormatWith(sid); } string itemcode = url.GetMatchingValues("/view/(.+?)/", "/view/", "/").FirstOrDefault() ?? ""; if (itemcode.IsNullEmpty()) { return(null); } string data = Net2.GetRemoteHtmlCode4(apiUrl.FormatWith(itemcode), Encoding.UTF8) ?? ""; string title = data.GetMatchingValues("\"title\":\"(.+?)\"", "\"title\":\"", "\"").FirstOrDefault() ?? ""; string img = data.GetMatchingValues("\"picUrl\":\"(.+?)\"", "\"picUrl\":\"", "\"").FirstOrDefault() ?? ""; string flv = "http://www.tudou.com/v/{0}/v.swf".FormatWith(itemcode); return(new VideoInfo() { PicUrl = img, Title = title, Url = flv }); }
/// <summary> /// 取指定URL的视频资料 /// </summary> /// <param name="url">网址</param> /// <returns>分享视频实体</returns> public VideoInfo GetVideoInfo(string url) { #region 测试数据 //http://v.qq.com/cover/7/72rfnl00qd0bml4.html //http://static.video.qq.com/TPout.swf?vid=84EU5iAW7G1 #endregion if (url.IndexOf(".swf?") != -1) { return(null); } string vid = url.IndexOf("vid=") != -1 ? url.Substring(url.IndexOf("vid=") + 4) : ""; string data = (Net2.GetRemoteHtmlCode4(url, Encoding.UTF8) ?? "").ReplaceRN(); string extTitle = string.Empty, extImg = string.Empty; vid = vid.Split('_')[0].Trim(); //Msg.WriteEnd(vid); if (vid.Length != 11) { vid = data.GetMatchingValues("vid:\"(.+?)\"", "vid:\"", "\"").FirstOrDefault() ?? ""; vid = vid.Trim().Split('|')[0]; vid = vid.Trim().Split(' ')[0]; if (vid.Length != 11) { string data2 = data.GetMatchingValues("<div class=\"tab_cont\" id=\"mod_videolist\">(.+?)</div>", "<div class=\"tab_cont\" id=\"mod_videolist\">", "</div>").FirstOrDefault() ?? ""; string li = data2.GetMatchingValues("<li>(.+?)</li>", "<li>", "</li>").FirstOrDefault() ?? ""; extTitle = li.GetMatchingValues("title=\"(.+?)\"", "title=\"", "\"").FirstOrDefault() ?? ""; vid = li.GetMatchingValues("id=\"(.+?)\"", "id=\"", "\"").FirstOrDefault() ?? ""; } } ; if (vid.Length != 11) { return(null); } string li2 = data.GetMatchingValues("<li id=\"li_{0}\">(.+?)</li>".FormatWith(vid), "<li id=\"li_{0}\">".FormatWith(vid), "</li>").FirstOrDefault() ?? ""; if (!li2.Trim().IsNullEmpty()) { extImg = li2.GetMatchingValues("src=\"(.+?)\"", "src=\"", "\"").FirstOrDefault() ?? ""; extTitle = li2.GetMatchingValues("\">(.+?)</a>", "\">", "</a>").FirstOrDefault() ?? ""; } string title = extTitle.Trim().IsNullEmpty() ? (data.GetMatchingValues("coverTitle:\"(.+?)\"", "coverTitle:\"", "\"").FirstOrDefault() ?? "").Trim() : extTitle; string img = extImg.Trim().IsNullEmpty() ? data.GetMatchingValues("coverPic:\"(.+?)\"", "coverPic:\"", "\"").FirstOrDefault() ?? "" : extImg; string flv = "http://static.video.qq.com/TPout.swf?vid={0}".FormatWith(vid); return(new VideoInfo() { PicUrl = img, Title = title, Url = flv }); }
/// <summary> /// 取指定URL的视频资料 /// </summary> /// <param name="url">网址</param> /// <returns>分享视频实体</returns> public VideoInfo GetVideoInfo(string url) { #region 测试数据 //http://www.56.com/u75/v_NjM2Nzk1OTI.html //http://player.56.com/v_NjM2Nzk1OTI.swf //http:\/\/img.v165.56.com\/images\/4\/19\/danny1103i56olo56i56.com_131844413759hd.jpg //,"Subject":"\u795e\u540c\u6b65\uff01\u8d85\u725b\u7537\u5973\u534f\u8c03\u624b\u4e2d\u821e\u8e48 ", //"Content":"\u8d85\u5f3a\u7684\u624b\u4e2d\u8fd0\u52a8\uff0c\u5728\u6781\u5feb\u7684\u901f\u5ea6\u4e0b\u8fbe\u5230\u60ca\u4eba\u7684\u4e00\u81f4\u3002 ", //"user_name":"danny1103 ", //"img":"http:\/\/img.v165.56.com\/images\/4\/19\/danny1103i56olo56i56.com_131844413759hd.jpg " //http://v.56.com/API/zhuantie.php?site=weibo&id=NjM2Nzk1OTI&pct=1 #endregion if (url.EndsWith(".swf")) { string sid = url.GetMatchingValues("com/(.+?).swf", "com/", ".swf").FirstOrDefault() ?? ""; if (sid.IsNullEmpty()) { return(null); } string weibo_data = Net2.GetRemoteHtmlCode4("http://v.56.com/API/zhuantie.php?site=weibo&id={0}&pct=1".FormatWith(sid.Right(sid.Length - 2)), Encoding.UTF8) ?? ""; string sina = weibo_data.GetMatchingValues("window.location='(.+?)'", "window.location='", "'").FirstOrDefault() ?? ""; string sina_data = Net2.GetRemoteHtmlCode4(sina, Encoding.UTF8) ?? ""; string _title = sina_data.GetMatchingValues("<textarea cols=\"20\" rows=\"5\" id=\"fw_content\">(.+?) http://", "<textarea cols=\"20\" rows=\"5\" id=\"fw_content\">", " http://").FirstOrDefault() ?? ""; string _img = sina_data.GetMatchingValues("<img src=\"(.+?)\" alt=\"\" width=\"120\" height=\"80\" /", "<img src=\"", "\" alt=\"\" width=\"120\" height=\"80\" /").FirstOrDefault() ?? ""; return(new VideoInfo() { PicUrl = _img, Title = _title, Url = url }); } string id = url.GetMatchingValues("/v_(.+?).html", "/v_", ".html").FirstOrDefault() ?? ""; string data = Net2.GetRemoteHtmlCode4(url, Encoding.UTF8) ?? ""; string title = (data.GetMatchingValues("\"Subject\":\"(.+?)\"", "\"Subject\":\"", "\"").FirstOrDefault() ?? "").Trim(); string img = (data.GetMatchingValues("\"img\":\"(.+?)\"", "\"img\":\"", "\"").FirstOrDefault() ?? "").Replace("\\/", "/").Trim(); string flv = "http://player.56.com/v_{0}.swf".FormatWith(id); title = title.Ascii2Native(); return(new VideoInfo() { PicUrl = img, Title = title, Url = flv }); }
/// <summary> /// 取指定URL的视频资料 /// </summary> /// <param name="url">网址</param> /// <returns>分享视频实体</returns> public VideoInfo GetVideoInfo(string url) { #region 测试数据 //http://v.pptv.com/show/BFhJxibK6JGJ43EQ.html //http://player.pptv.com/v/BFhJxibK6JGJ43EQ.swf //分享到新浪微博 //http://v.t.sina.com.cn/share/share.php?c=spr_web_bd_pplive_weibo //&url=http%3A%2F%2Fv.pptv.com%2Fshow%2FBFhJxibK6JGJ43EQ.html //&title=%E5%A8%B1%E4%B9%90%E6%92%AD%E6%8A%A5-20111019-%E4%BA%94%E6%98%9F%E6%83%8A%E7%8E%B0%E5%B1%B1%E5%AF%A8%E7%89%88%E7%9A%84%E8%A5%BF%E5%8D%95%E5%A5%B3%E5%AD%A9 //&source=PPLive%E7%BD%91%E7%BB%9C%E7%94%B5%E8%A7%86 //&sourceUrl=http%3A%2F%2Fwww.pptv.com //&content=utf-8 //&pic= //&appkey=1938876518 //<a target="_blank" title="分享到新浪微博" href="http://v.t.sina.com.cn/share/share.php?c=spr_web_bd_pplive_weibo&url=http%3A%2F%2Fv.pptv.com%2Fshow%2FBFhJxibK6JGJ43EQ.html&title=%E5%A8%B1%E4%B9%90%E6%92%AD%E6%8A%A5-20111019-%E4%BA%94%E6%98%9F%E6%83%8A%E7%8E%B0%E5%B1%B1%E5%AF%A8%E7%89%88%E7%9A%84%E8%A5%BF%E5%8D%95%E5%A5%B3%E5%AD%A9&source=PPLive%E7%BD%91%E7%BB%9C%E7%94%B5%E8%A7%86&sourceUrl=http%3A%2F%2Fwww.pptv.com&content=utf-8&pic=&appkey=1938876518" class="ico_2"></a> #endregion if (url.EndsWith(".swf")) { string sid = url.GetMatchingValues("/v/(.+?).swf", "/v/", ".swf").FirstOrDefault() ?? ""; if (sid.IsNullEmpty()) { return(null); } url = "http://v.pptv.com/show/{0}.html".FormatWith(sid); } string data = (Net2.GetRemoteHtmlCode4(url, Encoding.UTF8) ?? "").ReplaceRN(); string title = data.GetMatchingValues("<h2>《(.+?)》评论</h2>", "<h2>《", "》评论</h2>").FirstOrDefault() ?? ""; string sina = data.GetMatchingValues("<a target=\"_blank\" title=\"分享到新浪微博\" href=\"(.+?)\" class=\"ico_2\"></a>", "<a target=\"_blank\" title=\"分享到新浪微博\" href=\"", "\" class=\"ico_2\"></a>").FirstOrDefault() ?? ""; string sina_code = Net2.GetRemoteHtmlCode4(sina, Encoding.UTF8) ?? ""; string img = sina_code.GetMatchingValues("<img src=\"(.+?)\" alt=\"\" width=\"120\" height=\"80\" /", "<img src=\"", "\" alt=\"\" width=\"120\" height=\"80\" /").FirstOrDefault() ?? ""; //string flv = data.GetMatchingValues("<input type=\"text\" class=\"txt\" readonly=\"readonly\" value=\"(.+?)\" id=\"fx_btn_txt2\" />", "<input type=\"text\" class=\"txt\" readonly=\"readonly\" value=\"", "\" id=\"fx_btn_txt2\" />").FirstOrDefault() ?? ""; string flv = data.GetMatchingValues("<label>flash地址:</label> <input type=\"text\" class=\"txt\" readonly=\"readonly\" value=\"(.+?)\" id=\"fx_btn_txt2\" />", "<label>flash地址:</label> <input type=\"text\" class=\"txt\" readonly=\"readonly\" value=\"", "\" id=\"fx_btn_txt2\" />").FirstOrDefault() ?? ""; return(new VideoInfo() { PicUrl = img, Title = title, Url = flv }); }
/// <summary> /// 取登录账号信息 /// </summary> /// <returns>取登录账号信息</returns> public UserInfo GetUserInfo() { string code = Request2.GetQ("code").Trim(); UserInfo user = new UserInfo(); List <UrlParameter> param = new List <UrlParameter>(); param.Add(new UrlParameter("client_id", config.AppKey)); param.Add(new UrlParameter("redirect_uri", config.RedirectUrl)); param.Add(new UrlParameter("client_secret", config.AppSecret)); param.Add(new UrlParameter("code", code)); param.Add(new UrlParameter("grant_type", "authorization_code")); param.Sort(new UrlParameterCompre()); string data = HttpHelper.SendPost(access_token, OAuthCommon.GetUrlParameter(param), "application/x-www-form-urlencoded"); user.Token = data.GetMatchingValues("\"access_token\":\"(.+?)\"", "\"access_token\":\"", "\"").FirstOrDefault() ?? ""; data = Net2.GetRemoteHtmlCode4(user_info + "?access_token=" + user.Token, Encoding.UTF8); user.UserID = data.GetMatchingValues("\"id\": \"(.+?)\"", "\"id\": \"", "\"").FirstOrDefault() ?? ""; user.Name = data.GetMatchingValues("\"name\": \"(.+?)\"", "\"name\": \"", "\"").FirstOrDefault() ?? ""; user.Sex = (data.GetMatchingValues("\"gender\": \"(.+?)\"", "\"gender\": \"", "\"").FirstOrDefault() ?? "male") == "male" ? 1 : 0; string url = data.GetMatchingValues("\"link\": \"(.+?)\"", "\"link\": \"", "\"").FirstOrDefault() ?? ""; if (!url.Trim().IsNullEmpty()) { data = Net2.GetRemoteHtmlCode4(url, Encoding.UTF8).ReplaceRN(); url = data.GetMatchingValues("<img id=\"snsupermeic1_usertile\" errsrc=\"(.+?)\" onload=\"ic_onTL\\(this\\)\"", "<img id=\"snsupermeic1_usertile\" errsrc=\"", "\" onload=\"ic_onTL(this)\"").FirstOrDefault() ?? ""; int index = url.IndexOf("src=\""); if (index != -1) { user.Header = url.Substring(index + 5); } } return(user); }
/// <summary> /// 取指定URL的视频资料 /// </summary> /// <param name="url">网址</param> /// <returns>分享视频实体</returns> public VideoInfo GetVideoInfo(string url) { #region 测试数据 //http://v.youku.com/v_playlist/f16352267o1p2.html //http://v.youku.com/v_show/id_XMzEzNzAxNzky.html //http://player.youku.com/player.php/Type/Folder/Fid/16352267/Ob/1/Pt/3/sid/XMzEyMjE4Nzk2/v.swf <input type="text" id="link2" value="http://player.youku.com/player.php/sid/XMzEzNzAxNzky/v.swf" /> //http://v.t.sina.com.cn/share/share.php?appkey=2684493555 //&url=http://v.youku.com/v_show/id_XMzEyMTg4NDg4.html //&title=%E4%B8%AD%E5%9B%BD%E7%BD%91%E5%95%86%E7%BB%B4%E6%9D%83%E5%8D%8F%E4%BC%9A%E3%80%90%E4%BB%8A%E6%97%A5%E4%B8%80%E7%BA%BF%E6%9B%9D%E5%85%89%E6%B7%98%E5%AE%9D%E5%95%86%E5%9F%8E%E5%9C%88%E9%92%B1%E4%B8%8A%E5%B8%82%EF%BC%8C%E4%B8%8D%E9%A1%BE%E4%B8%AD%E5%B0%8F%E5%8D%96%E5%AE%B6%E7%9A%84%E5%88%A9%E7%9B%8A%E3%80%91 //&ralateUid=1642904381 //&source=%E4%BC%98%E9%85%B7%E7%BD%91 //&sourceUrl=http%3A%2F%2Fwww.youku.com%2F //&content=utf8 //&pic=http://g4.ykimg.com/0100641F464E95CD3FFA0D017E2DA67B689550-EC9D-F339-9651-6D2988EF2CBA //http://v.t.sina.com.cn/share/share.php?appkey=2684493555 //&url=http://v.youku.com/v_show/id_XMzEzMzI3NzI0.html //&ralateUid=1642904381 //&title=%E6%96%AF%E8%92%82%E8%8A%AC%C2%B7%E9%87%91%E6%81%90%E6%80%96%E5%B0%8F%E8%AF%B4%E6%94%B9%E7%BC%96%E3%80%8A%E5%B0%B8%E9%AA%A8%E8%A2%8B%E3%80%8B%E6%8B%8D%E6%91%84%E8%8A%B1%E7%B5%AE //&source=%E4%BC%98%E9%85%B7%E7%BD%91 //&sourceUrl=http%3A%2F%2Fwww.youku.com%2F //&content=utf8 //&pic=http://g2.ykimg.com/0100641F464E9ACEF9F2A700FC8CA4584613FE-429E-B3BD-B7F4-87ECF311C25D" target="_blank"><img src="http://static.youku.com/v1.0.0706/v/img/ico_sina.gif" />新浪微博</a> #endregion if (url.EndsWith("/v.swf")) { string sid = url.GetMatchingValues("sid/(.+?)/v.swf", "sid/", "/v.swf").FirstOrDefault() ?? ""; if (sid.IsNullEmpty()) { return(null); } url = "http://v.youku.com/v_show/id_{0}.html".FormatWith(sid); } string data = Net2.GetRemoteHtmlCode4(url, Encoding.UTF8) ?? ""; //string[] sina = (data.GetMatchingValues("charset=\"400-03-10\" id=\"s_sina\" href=\"(.+?)\" target=\"_blank\"><img src=\"http://static.youku.com/v1.0.0706/v/img/ico_sina.gif\"", "charset=\"400-03-10\" id=\"s_sina\" href=\"", "\" target=\"_blank\"><img src=\"http://static.youku.com/v1.0.0706/v/img/ico_sina.gif\"").FirstOrDefault() ?? "").Split('&'); string[] sina = (data.GetMatchingValues("charset=\"400-03-10\" id=\"s_sina\" href=\"(.+?)\" target=\"_blank\"><img", "charset=\"400-03-10\" id=\"s_sina\" href=\"", "\" target=\"_blank\"><img").FirstOrDefault() ?? "").Split('&'); string img = "", title = ""; if (sina.Length == 8) { img = sina[7].Right(sina[7].Length - 4); title = sina[2].Right(sina[2].Length - 6).UrlDecode(); } else { //sina = (data.GetMatchingValues("charset=\"400-03-10\" id=\"s_sina\" href=\"(.+?)\" target=\"_blank\"><img src=\"http://static.youku.com/v1.0.0706/v/img/ico_sina.gif\"", "charset=\"400-03-10\" id=\"s_sina\" href=\"", "\" target=\"_blank\"><img src=\"http://static.youku.com/v1.0.0706/v/img/ico_sina.gif\"").FirstOrDefault() ?? "").Split('&'); sina = (data.GetMatchingValues("charset=\"400-03-10\" id=\"s_sina\" href=\"(.+?)\" target=\"_blank\"><img", "charset=\"400-03-10\" id=\"s_sina\" href=\"", "\" target=\"_blank\"><img").FirstOrDefault() ?? "").Split('&'); if (sina.Length == 8) { img = sina[7].Right(sina[7].Length - 4); title = sina[3].Right(sina[3].Length - 6).UrlDecode(); } } string flv = data.GetMatchingValues("<input type=\"text\" id=\"link2\" value=\"(.+?)\" />", "<input type=\"text\" id=\"link2\" value=\"", "\" />").FirstOrDefault() ?? ""; if (title.IndexOf("优酷") != -1) { title = title.Left(title.IndexOf("优酷")).Trim().TrimEnd('-').Trim(); } return(new VideoInfo() { PicUrl = img, Title = title, Url = flv }); }