昨天在这个地址:http://www.21cx.com/software/catalog21/43.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、用程序转换格式:
前台:
<%@ 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" runat="server"
width="312px" height="240px" textmode="multiline"></asp:textbox>
<asp:button id="button1" 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();
}
}
}
新闻热点
疑难解答
图片精选