昨天在这个地址:http://www.vipcn.com看到一个非常漂亮的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、用程序转换格式:
前台:
<%@ page language="c#" codebehind="readandwritexml.aspx.cs" autoeventwireup="false" inherits="读取番茄花园的mp3.readandwritexml" validaterequest=false%>
<!doctype html public "-//w3c//dtd html 4.0 transitional//en" >
<html>
<head>
<title>读取番茄花园mp3列表</title>
<meta content="microsoft visual studio .net 7.1" name="generator">
<meta content="c#" name="code_language">
<meta content="javascript" name="vs_defaultclientscript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetschema">
</head>
<body ms_positioning="gridlayout">
<form id="form1" method="post" runat="server">
<font face="宋体">
<asp:textbox id="textbox1" style="z-index: 101; left: 56px; position: absolute; top: 32px" runat="server"
width="312px" height="240px" textmode="multiline"></asp:textbox>
<asp:button id="button1" style="z-index: 102; left: 160px; position: absolute; top: 288px" runat="server"
width="96px" text="修正~"></asp:button></font></form>
</body>
</html>
后台:
using system;
using system.collections;
using system.componentmodel;
using system.data;
using system.drawing;
using system.web;
using system.web.sessionstate;
using system.web.ui;
using system.web.ui.webcontrols;
using system.web.ui.htmlcontrols;
using system.io;
using system.net;
using system.text;
using system.text.regularexpressions;
namespace 读取番茄花园的mp3
{
/// <summary>
/// webform1 的摘要说明。
/// </summary>
public class readandwritexml : system.web.ui.page
{
protected system.web.ui.webcontrols.textbox textbox1;
protected system.web.ui.webcontrols.button button1;
private string pageurl = "";
private void page_load(object sender, system.eventargs e)
{
// 在此处放置用户代码以初始化页面
if(!ispostback)
{
///首先读取番茄花园的acx文件(http://tomatolei.com/bbs/t_playlist.asx)
///
pageurl = "http://tomatolei.com/bbs/t_playlist.asx";
webclient wc = new webclient();
wc.credentials = credentialcache.defaultcredentials;
byte[] pagedata = wc.downloaddata(pageurl);
string result = encoding.default.getstring(pagedata);
textbox1.text=result;
}
}
#region web 窗体设计器生成的代码
override protected void oninit(eventargs e)
{
//
// codegen: 该调用是 asp.net web 窗体设计器所必需的。
//
initializecomponent();
base.oninit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void initializecomponent()
{
this.button1.click += new system.eventhandler(this.button1_click);
this.load += new system.eventhandler(this.page_load);
}
#endregion
private void button1_click(object sender, system.eventargs e)
{
string temp=textbox1.text;
textbox1.text="<musics firstrun=\"1\">";
textbox1.text+=temp;
textbox1.text=textbox1.text.replace("<asx version=3.0>","");
textbox1.text=textbox1.text.replace("<param name=\"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>","<music name=\"");
textbox1.text=textbox1.text.replace("</title>","\"");
textbox1.text=textbox1.text.replace("<ref href=","addres=");
textbox1.text+="</musics>";
//textbox1.text=textbox1.text.replace("\r\n","");
/// 下面开始生成 1.xml文件
///
streamwriter swfromfilestreamutf8buffer=new streamwriter(server.mappath("./")+"1.xml",false,system.text.encoding.utf8,512);
swfromfilestreamutf8buffer.write(textbox1.text);
swfromfilestreamutf8buffer.flush();
swfromfilestreamutf8buffer.close();
}
}
}
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器