zoukankan      html  css  js  c++  java
  • 一个简单的优酷视频链接探测与分享功能

    这里只是一个展示,实际可以使用Ajax方式调用。另外还可以加入短网址功能毕竟这种视频地址一般不短。
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        
    <title></title>
    </head>
    <body>
        
    <form id="form1" runat="server">
        
    <div>
        链接地址:
    <asp:TextBox ID="TextBox1" runat="server" Height="32px" 
                Width
    ="438px"></asp:TextBox><br />
                    页面标题:
    <asp:TextBox ID="TextBox3" runat="server" Height="32px" 
                Width
    ="438px"></asp:TextBox><br />
        视频代码:
    <asp:TextBox ID="TextBox2" runat="server" TextMode="MultiLine" 
                Height
    ="173px" Width="439px"></asp:TextBox><br />
        
    <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" /><br />
            耗时:
    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
        
    </div>
        
    <div id="div" runat="server"></div>
        
    </form>
    </body>
    </html>

    C#代码using System;

    using System.Collections.Generic;
    using System.Text;
    using System.Web;
    using System.Web.UI;
    using System.Net;
    using HtmlAgilityPack;

    public partial class Default3 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            var time1 = DateTime.Now;
            WebRequest request1 = WebRequest.Create(TextBox1.Text);
            var str = request1.GetResponse().GetResponseStream();
            var doc = new HtmlAgilityPack.HtmlDocument();
            doc.Load(str,true);
            var nodes = doc.DocumentNode.SelectSingleNode("//title");
            TextBox3.Text = nodes.InnerText;
            var flv = doc.GetElementbyId("link3");
            TextBox2.Text = flv.Attributes["value"].Value;
            div.InnerHtml = TextBox2.Text;
            Label1.Text = (DateTime.Now - time1).TotalMilliseconds.ToString();
        }
    }
  • 相关阅读:
    Java数据结构和算法——汉诺塔问题
    svn的使用
    Struts+iBatis+Spring+mysql整合开发
    Java Collection
    IOS推送功能的实现(javapns)
    [工具库]JFileDownloader工具类——多线程下载网络文件,并保存在本地
    xsl 中 foreach 的使用
    网页制作技巧24条
    js 实现 datagrid 鼠标移动时datagrid 表的该变
    How to extend ASP.NET datagrid for multiselection of data rows.
  • 原文地址:https://www.cnblogs.com/1000/p/1974764.html
Copyright © 2011-2022 走看看