当前位置: 首页 > 图文教程 > 网络编程 > ASP.NET > 开发ASP.NET下的MP3小偷程序

ASP.NET
FreeTextBox(版本3.1.6)在ASP.Net 2.0中使用方法
.NET 常用功能和代码小结
在 .NET Framework 2.0 中未处理的异常导致基于 ASP.NET 的应用程序意外退出
asp.net IList查询数据后格式化数据再绑定控件
asp.net sql存储过程
asp.net 简单实现禁用或启用页面中的某一类型的控件
asp.net(c#)获取内容第一张图片地址的函数
The remote procedure call failed and did not execute的解决办法
ASP.NET 在线文件管理
asp.net 读取并修改config文件实现代码
ASP.NET Cookie 操作实现
asp.net Silverlight中的模式窗体
Silverlight中动态获取Web Service地址
asp.net Silverlight应用程序中获取载体aspx页面参数
asp.net 水晶报表隔行换色实现方法
asp.net 获取Gridview隐藏列的值
手动把asp.net的类生成dll文件的方法
asp.net 使用ObjectDataSource控件在ASP.NET中实现Ajax真分页
动态指定任意类型的ObjectDataSource对象的查询参数
asp.net Md5的用法小结

开发ASP.NET下的MP3小偷程序


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 68 ::
收藏到网摘: n/a

昨天在这个地址:http://code.knowsky.com/down/86.html看到一个非常漂亮的MP3的FLASH播放器,真是好看。可是一调试发现里面的歌太老,要不就是听不了。MP3资源都在互联网上,有时听不了也是正常,但大多数不好用,真是用处不大了。仔细分析了一下它的源码,原来是读取目录下的1.xml,2.xml..4.xml文件。我经常在番茄花园听歌,也就是http://www.tomatolei.com,就想能不能把番茄的MP3资源放到这里来放呢?这不就是大家常说的MP3小偷的功能吗?说干就干!

1、分析一下番茄花园的歌来源:PageUrl="http://tomatolei.com/bbs/T_playlist.asx";

2、目标地址:1.xml

3、用程序转换格式:

前台:

<%@Pagelanguage="c#"Codebehind="ReadAndWriteXml.aspx.cs"AutoEventWireup="false"Inherits="读取番茄花园的MP3.ReadAndWriteXml"validateRequest=false%>
<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.0Transitional//EN">
<HTML>
<HEAD>
<title>读取番茄花园MP3列表</title>
<metacontent="MicrosoftVisualStudio.NET7.1"name="GENERATOR">
<metacontent="C#"name="CODE_LANGUAGE">
<metacontent="JavaScript"name="vs_defaultClientScript">
<metacontent="http://schemas.microsoft.com/intellisense/ie5"name="vs_targetSchema">
</HEAD>
<bodyMS_POSITIONING="GridLayout">
<formid="Form1"method="post"runat="server">
<FONTface="宋体">
<asp:TextBoxid="TextBox1"style="Z-INDEX:101;LEFT:56px;POSITION:absolute;TOP:32px"runat="server"
Width="312px"Height="240px"TextMode="MultiLine"></asp:TextBox>
<asp:Buttonid="Button1"style="Z-INDEX:102;LEFT:160px;POSITION:absolute;TOP:288px"runat="server"
Width="96px"Text="修正~"></asp:Button></FONT></form>
</body>
</HTML>

后台:

usingSystem;
usingSystem.Collections;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Web;
usingSystem.Web.SessionState;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
usingSystem.Web.UI.HtmlControls;
usingSystem.IO;
usingSystem.Net;
usingSystem.Text;
usingSystem.Text.RegularExpressions;
namespace读取番茄花园的MP3
{
 ///<summary>
 ///WebForm1的摘要说明。
 ///</summary>
 publicclassReadAndWriteXml:System.Web.UI.Page
 {
protectedSystem.Web.UI.WebControls.TextBoxTextBox1;
protectedSystem.Web.UI.WebControls.ButtonButton1;
privatestringPageUrl="";

privatevoidPage_Load(objectsender,System.EventArgse)
{
 //在此处放置用户代码以初始化页面
 if(!IsPostBack)
 {
///首先读取番茄花园的acx文件(http://tomatolei.com/bbs/T_playlist.asx)
///
PageUrl="http://tomatolei.com/bbs/T_playlist.asx";
WebClientwc=newWebClient();
wc.Credentials=CredentialCache.DefaultCredentials;
Byte[]pageData=wc.DownloadData(PageUrl);
stringResult=Encoding.Default.GetString(pageData);
TextBox1.Text=Result;

 }
}

#regionWeb窗体设计器生成的代码
overrideprotectedvoidOnInit(EventArgse)
{
 //
 //CODEGEN:该调用是ASP.NETWeb窗体设计器所必需的。
 //
 InitializeComponent();
 base.OnInit(e);
}

///<summary>
///设计器支持所需的方法-不要使用代码编辑器修改
///此方法的内容。
///</summary>
privatevoidInitializeComponent()
{
 this.Button1.Click+=newSystem.EventHandler(this.Button1_Click);
 this.Load+=newSystem.EventHandler(this.Page_Load);
}
#endregion

privatevoidButton1_Click(objectsender,System.EventArgse)
{
 stringtemp=TextBox1.Text;
 TextBox1.Text="<musicsfirstRun=\"1\">";
 TextBox1.Text+=temp;

 TextBox1.Text=TextBox1.Text.Replace("<AsxVersion=3.0>","");
 TextBox1.Text=TextBox1.Text.Replace("<ParamName=\"AllowShuffle\"Value=\"yes\"/>","");
 TextBox1.Text=TextBox1.Text.Replace("</Asx>","");

 TextBox1.Text=TextBox1.Text.Replace("</Entry>","");
 TextBox1.Text=TextBox1.Text.Replace("<Entry>","");

 TextBox1.Text=TextBox1.Text.Replace("<Title>","<musicname=\"");
 TextBox1.Text=TextBox1.Text.Replace("</Title>","\"");
 
 TextBox1.Text=TextBox1.Text.Replace("<Refhref=","addres=");

 TextBox1.Text+="</musics>";

 //TextBox1.Text=TextBox1.Text.Replace("\r\n","");
 ///下面开始生成 1.xml文件
 ///
 StreamWriterswFromFileStreamUTF8Buffer=newStreamWriter(Server.MapPath("./")+"1.xml",false,System.Text.Encoding.UTF8,512);
 swFromFileStreamUTF8Buffer.Write(TextBox1.Text);
 swFromFileStreamUTF8Buffer.Flush();
 swFromFileStreamUTF8Buffer.Close();
}
 }
}