ASP讀取XML執行個體 優酷專輯採集程式 雷鋒版

來源:互聯網
上載者:User

複製代碼 代碼如下:<title>雷鋒|優酷-專輯 採集程式</title></head>
<form name="form1" method="post" action="?action=add">
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="1" class="tableBorder">
<tr><th colspan="2" align="center" class="tableHeaderText"><<<< <font color=red>雷鋒|優酷-專輯 採集程式</font> >>>></td></tr>
<tr><td align="center"><a href="http://www.youku.com/playlist/" target="_blank">點我尋找優酷專輯</a>
</td>
</tr>
<tr><td bgcolor="#FFFFFF" align="center">專輯地址:<input name="maxz" type="text" value="<%=Request("maxz")%>" size="50"></td></tr>
<tr><td align="center" bgcolor="#FFFFFF">例如專輯:http://www.youku.com/playlist_show/id_2344971.html</td></tr>
<tr><td align="center" bgcolor="#FFFFFF"><input name="action" type="submit" id="action" value="提交分析該專輯地址"></td></tr>
<tr><td align="center" bgcolor="#FFFFFF"></td></tr>
</table>
</form>
<%

if Request("action")="add" Then
maxz=request.Form("maxz")

v_urla=Split(maxz,"/id_")(1)
v_urlb=Replace(v_urla,".html","")
v_url="http://www.youku.com/playlist/rss/id/4014024"&v_urlb
response.write "<div align=""center""><a href="&v_url&" target=_blank >當前專輯的XML:"&v_url&"</a></div>"

Function GetPageContent(Url)
Dim HTTPObj
On Error Resume Next
Set HTTPObj = Server.CreateObject("Microsoft.XMLHTTP")
With HTTPObj
.Open "Get", Url, False, "", ""
.Send
End With
if HTTPObj.Readystate <> 4 then
Set HTTPObj = Nothing
GetPageContent = False
Exit Function
end if
GetPageContent = replace(HTTPObj.responseText,"UTF-8","gb2312")
Set HTTPObj = Nothing
End Function
strXML=GetPageContent(""&v_url&"")
Set objXML = Server.CreateObject("Microsoft.XMLDOM")
objXML.validateonparse = true
objXML.async=false
objXML.loadXML(strXML)
set objRootElement = objXML.documentElement
if not isObject(objRootElement) then
Response.Write("no file loaded")
else
Set ChannelList=objXML.getElementsByTagName("item")
if isnull(objXML.getElementsByTagName("item") ) then
response.Write("讀取失敗")
response.End()
else
Set Statistics=objXML.getElementsByTagName("title")
set KeywordList=objXML.getElementsbytagname("lastBuildDate")

'response.write "共有:"&keywordlist.length-1&"個頻道"
'response.write "<div align=""center""><h4>專輯名稱:"&Statistics.item(0).text&"</h4>"

v_name=REPLACE(Statistics.item(0).text,"優酷-專輯-","")
zt_name=REPLACE(v_name,"的視頻","")
response.write "<div align=""center""><h4>專輯名稱:<font color=red>"&zt_name&"</font></h4>"
response.write "<center><form method=""post"" action=""../admin_add.asp"">"
response.write "<input type=""hidden"" name=""db_channel"" value="&zt_name&" /><br>"
response.write "<input type=""hidden"" name=""db_player"" value=""youku"" />"
response.write "<textarea name=""db_url"" rows=""15"" cols=""100"">"
for j=0 to ChannelList.length-1
dim ibb
response.write ""&ChannelList.item(j).childnodes(0).text&"$"&ChannelList.item(j).childnodes(8).text&chr(13)&""
ibb=ibb+1
next
response.write "</textarea><br /><input type=""submit"" value=""修改好了提交"" /></form></center>"
response.write "<div align=""center""><h4>共提取到:<font color=red>"&ibb&"</font>個節目核實後提交</h4></div><br>"
end if
end if
%>
<%End If %>

以上程式是以優酷的專輯列表為例做的一個 asp讀取xml的執行個體!
將以上代碼儲存為 XML.ASP 在IIS環境下運行就可以採集優酷專輯的資料了!

其實上面的擷取的是下面的xml檔案 複製代碼 代碼如下:<?xml version="1.0" encoding="utf-8"?>
<!-- generator="Novajax Feed Writer" -->
<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd">
<channel>
<title>優酷-專輯-乾隆與香妃(27集)的視頻</title>
<description>優酷專輯乾隆與香妃(27集)的視頻</description>
<link>http://www.youku.com/playlist/</link>
<lastBuildDate>Wed, 16 Dec 2009 13:34:06 +0800</lastBuildDate>
<generator>Novajax Feed Writer</generator>
<image>
<url>http://www.youku.com/index/img/youkulogo.gif</url>
<title>優酷網-中國第一視頻網,提供視頻播放,視頻發布,視頻搜尋</title>
<link>http://www.youku.com</link>
<description>視頻服務平台,提供視頻播放,視頻發布,視頻搜尋、視頻分享</description>
</image>
<item>
<title>乾隆與香妃01</title>
<link>http://www.youku.com/v_show/id_XMTM4NTY5NDk2_rss.html</link>
<description><![CDATA[<a href="http://www.youku.com/v_show/id_XMTM4NTY5NDk2_rss.html"><img src="http://g3.ykimg.com/0100641F464B178EA61F9F011876CAD9220D5D-8DAE-B491-FD1B-138F2DC75B23" border="0" width="120" height="90" vspace="4" hspace="4" title="乾隆與香妃01" target="_blank" /></a> <a href="http://www.youku.com/v_show/id_XMTM4NTY5NDk2_rss.html"><img src="http://g1.ykimg.com/" border="0" width="120" height="90" vspace="4" hspace="4" title="乾隆與香妃01" target="_blank" /></a> <a href="http://www.youku.com/v_show/id_XMTM4NTY5NDk2_rss.html"><img src="http://g1.ykimg.com/" border="0" width="120" height="90" vspace="4" hspace="4" title="乾隆與香妃01" target="_blank" /></a> <p></p>]]></description>
<itunes:duration>43:42</itunes:duration>
<itunes:keywords>尊龍,努爾比亞,恬妞,翁虹,阿依努爾,古海爾,譚非翎,瓦力伊,斯拉木江斯</itunes:keywords>
<author>為傑沉淪</author>
<comments>http://www.youku.com/v_show/id_XMTM4NTY5NDk2_rss.html#comments</comments>
<pubDate>Wed, 16 Dec 2009 13:34:06 +0800</pubDate>
<guid>34642374</guid>
<enclosure type="application/x-shockwave-flash" url="http://player.youku.com/player.php/sid/34642374/v.swf"></enclosure>
</item>
<item>
<title>乾隆與香妃02</title>
<link>http://www.youku.com/v_show/id_XMTM4NTY5NTI4_rss.html</link>
<description><![CDATA[<a href="http://www.youku.com/v_show/id_XMTM4NTY5NTI4_rss.html"><img src="http://g2.ykimg.com/0100641F464B178D99EF1F011876CA86F7B34B-B71C-2F1E-36B5-D0804F32AB42" border="0" width="120" height="90" vspace="4" hspace="4" title="乾隆與香妃02" target="_blank" /></a> <a href="http://www.youku.com/v_show/id_XMTM4NTY5NTI4_rss.html"><img src="http://g1.ykimg.com/" border="0" width="120" height="90" vspace="4" hspace="4" title="乾隆與香妃02" target="_blank" /></a> <a href="http://www.youku.com/v_show/id_XMTM4NTY5NTI4_rss.html"><img src="http://g1.ykimg.com/" border="0" width="120" height="90" vspace="4" hspace="4" title="乾隆與香妃02" target="_blank" /></a> <p></p>]]></description>
<itunes:duration>41:26</itunes:duration>
<itunes:keywords>尊龍,努爾比亞,恬妞,翁虹,阿依努爾,古海爾,譚非翎,瓦力伊,斯拉木江斯</itunes:keywords>
<author>為傑沉淪</author>
<comments>http://www.youku.com/v_show/id_XMTM4NTY5NTI4_rss.html#comments</comments>
<pubDate>Wed, 16 Dec 2009 13:34:06 +0800</pubDate>
<guid>34642382</guid>
<enclosure type="application/x-shockwave-flash" url="http://player.youku.com/player.php/sid/34642382/v.swf"></enclosure>
</item>
</channel>
</rss>

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.