大家好,今天小编来为大家解答以下的问题,关于会员视频系统网站源码分享,会员下载网站源码这个很多人还不知道,现在让我们一起来看看吧!
小编这里只是讲个示例,只实现一个网站,其它网站方式类似。
部署方法:
把下面代码另存为GetUrl.ashx文件
放入支持.net2.0以上空间
访问:http://域名/GetUrl.ashx?url=http://www.iqiyi.com/v_19rr78nouw.html
会自动解析出播放地址
<%[url=home.php?mod=space&uid=402414]@[/url]WebHandlerLanguage=”C#”Class=”GetURL”%>
usingSystem;
usingSystem.Text;
usingSystem.Web;
usingSystem.Text.RegularExpressions;
usingSystem.Net;
usingSystem.IO;
usingSystem.Net.Security;
usingSystem.Security.Cryptography.X509Certificates;
publicclassGetURL:IHttpHandler
{
publicvoidProcessRequest(HttpContextcontext)
{
context.Response.ContentType=”text/html”;
stringvUrl=GetQueryString(“url”);//视频地址
if(!string.IsNullOrEmpty(vUrl))
{
stringapiUrl=”https://tyhttps.duapp.com/1040https/333.php?url=”+vUrl;//组合视频地址
stringdata=GetHttpWebRequest(apiUrl);//取回源代码
//截取需要Post提交数据
strings=GetValue(data,”api.php\\”,\\\\{“,”\\\\}”).Replace(“\\””,””).Replace(“:”,”=”).Replace(“,”,”&”).Replace(“”,””).Replace(“=//”,”://”);
stringpostData=this.GetHttpPostWebRequest(“https://tyhttps.duapp.com/1040https/api.php”,s);
if(postData.IndexOf(“\\”success\\”:1″)>-1)//返回JSON数据
{
stringtime=GetValue(postData,”time\\”:\\””,”\\””);
stringkey=GetValue(postData,”key\\”:\\””,”\\””);
stringurl=GetValue(postData,”url\\”:\\””,”\\””).Replace(“\\\\/”,”/”);
stringtype=GetValue(postData,”type\\”:\\””,”\\””);
if(url.IndexOf(“.mp4?”)>-1)//mp4地址
context.Response.Redirect(url);//直接跳转播放地址
else
context.Response.Redirect(postData);//直接跳转播放地址
}
}
}
///<summary>
///截取开始结束代码
///</summary>
privatestringGetValue(stringstr,strings,stringe)
{
Regexrg=newRegex(“(?<=(“+s+”))[.\\\\s\\\\S]*?(?=(“+e+”))”,RegexOptions.Multiline|RegexOptions.Singleline);
returnrg.Match(str).Value;
}
///<summary>
///URL取值
///</summary>
publicstringGetQueryString(stringstrName)
{
stringstrWord=HttpContext.Current.Request.QueryString[strName];
if(string.IsNullOrEmpty(strWord))return””;
returnstrWord;
}
///<summary>
///获取取源代码支持https
///</summary>
privatestringGetHttpWebRequest(stringurl)
{
Uriuri=newUri(url);
HttpWebRequestmyReq=(HttpWebRequest)WebRequest.Create(uri);
if(uri.Scheme==”https”)
{
ServicePointManager.Expect100Continue=false;
ServicePointManager.ServerCertificateValidationCallback=newRemoteCertificateValidationCallback(delegate(objectsender,X509Certificatecertificate,X509Chainchain,SslPolicyErrorssslPolicyErrors){returntrue;});
myReq.ProtocolVersion=HttpVersion.Version10;
}
myReq.UserAgent=”Mozilla/5.0(iPhone;CPUiPhoneOS9_1likeMacOSX)AppleWebKit/601.1.46(KHTML,likeGecko)Version/9.0Mobile/13B143Safari/601.1″;
//myReq.Accept=”*/*”;
//myReq.KeepAlive=true;
//myReq.Headers.Add(“Accept-Encoding”,”gzip,deflate,sdch”);
//myReq.Headers.Add(“Accept-Language”,”zh-CN,zh;q=0.8″);
myReq.Referer=”https://tyhttps.duapp.com/1040https/333.php?url=”+url;//设置来源网站
//myReq.Method=”get”;
Cookiec=newCookie();//设置cookies
c.Domain=uri.Host;
c.Name=”BAEID”;
c.Value=”8EED1F19C9DA87D24178E6FB54FBBE2E”;
c.Expires=DateTime.Now.AddDays(365);
CookieContainercookie=newCookieContainer();
cookie.Add(c);
myReq.CookieContainer=cookie;
HttpWebResponseresult=(HttpWebResponse)myReq.GetResponse();
StreamreceviceStream=result.GetResponseStream();
StreamReaderreaderOfStream=newStreamReader(receviceStream,Encoding.UTF8);
stringstrHTML=readerOfStream.ReadToEnd();
readerOfStream.Close();
receviceStream.Close();
result.Close();
returnstrHTML;
}
///<summary>
///Post提交取回源代码
///</summary>
///<returns></returns>
privatestringGetHttpPostWebRequest(stringurl,stringparam)
{
byte[]bs=Encoding.UTF8.GetBytes(param);
Uriuri=newUri(url);
HttpWebRequestmyReq=(HttpWebRequest)WebRequest.Create(uri);
if(uri.Scheme==”https”)
{
ServicePointManager.Expect100Continue=false;
ServicePointManager.ServerCertificateValidationCallback=newRemoteCertificateValidationCallback(delegate(objectsender,X509Certificatecertificate,X509Chainchain,SslPolicyErrorssslPolicyErrors){returntrue;});
myReq.ProtocolVersion=HttpVersion.Version10;
}
myReq.UserAgent=”Mozilla/5.0(iPhone;CPUiPhoneOS9_1likeMacOSX)AppleWebKit/601.1.46(KHTML,likeGecko)Version/9.0Mobile/13B143Safari/601.1″;
myReq.Accept=”*/*”;
//myReq.KeepAlive=true;
//myReq.Headers.Add(“Accept-Encoding”,”gzip,deflate,sdch”);
//myReq.Headers.Add(“Accept-Language”,”zh-CN,zh;q=0.8″);
myReq.Referer=”https://tyhttps.duapp.com/1040https/333.php?url=”+url;
myReq.Method=”POST”;
myReq.ContentType=”application/x-www-form-urlencoded”;
myReq.ContentLength=bs.Length;
myReq.ContentLength=bs.Length;
using(StreamreqStream=myReq.GetRequestStream())
{
reqStream.Write(bs,0,bs.Length);
}
using(WebResponsewr=myReq.GetResponse())
{
StreamreceviceStream=wr.GetResponseStream();
StreamReaderreaderOfStream=newStreamReader(receviceStream,Encoding.UTF8);
stringstrHTML=readerOfStream.ReadToEnd();
readerOfStream.Close();
returnstrHTML;
}
}
publicboolIsReusable
{
get
{
returnfalse;
}
}
}
学会了吗?动动手指给个关注哦。
会员视频系统网站源码分享和会员下载网站源码的问题分享结束啦,以上的文章解决了您的问题吗?欢迎您下次再来哦!
