using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System;
namespace Youku
{/// <summary>/// 优酷热门视频实体类/// </summary>public class YouHotVideo{public string Title { get; set; }public string ImgURI { get; set; }public string URI { get; set; }public YouHotVideo(string title, string imgUri, string uri){Title = title;ImgURI = imgUri;URI = uri;}public static List<YouHotVideo> GetALL(){var v = new StreamReader(HttpWebRequest.Create("").GetResponse().GetResponseStream(), Encoding.UTF8).ReadToEnd().Replace("<li ", "❇").Split('❇').Where(x => x.Contains("v_link") || x.Contains("v_thumb")).Select(x => x.Substring(x.IndexOf("http"))).Select(x => x.Remove(x.IndexOf(">"))).ToList();v = v.Select(x => x + v.ElementAt(v.IndexOf(x) + (v.IndexOf(x) == v.Count() - 1 ? 0 : 1))).ToList();return v.Where(x => v.IndexOf(x) % 2 == 0).Where(x => x.Contains("html") && x.Contains("ykimg")).Select(x => x.Replace("<", "<").Replace(">", ">").Replace(""", """).Replace(" ", " ")).ToList().Select(x => new YouHotVideo(x.Remove(x.LastIndexOf(""")).Substring(x.IndexOf("title") + 7), x.Remove((x.Contains("src") ? x.LastIndexOf(" src") : x.LastIndexOf(" alt")) - 1).Substring(x.IndexOf("ykimg") - 10), x.Remove(x.IndexOf("html") + 4))).ToList();}}
}namespace ConsoleApplicationDemo
{class Program{static void Main(string[] args){Youku.YouHotVideo.GetALL().ForEach(x =>{Console.WriteLine("标题:" + x.Title);Console.WriteLine("图片地址:" + x.ImgURI);Console.WriteLine("视频地址:" + x.URI);Console.WriteLine();});Console.ReadLine();}}
}
本文发布于:2024-02-02 00:24:48,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170681021440177.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |