昨天在這個地址: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();
}
}
}
新聞熱點
疑難解答
圖片精選