首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

上个美女玩玩

2012-11-03 
下个美女玩玩using Systemusing System.Collections.Genericusing System.Linqusing System.Textusing

下个美女玩玩

上个美女玩玩


using System;

using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Text.RegularExpressions;
using System.IO;

namespace DownLoad
{
    class Program
    {
        static void Main(string[] args)
        {
            WebClient wc = new WebClient();
            wc.Encoding = Encoding.UTF8;
            string url = "http://www.qqjay.com/html/old8/fzl/index.html";
            string html= wc.DownloadString(url);
            string regImage = "<img src=\"(.+)\"\\s+title =\"(.+)\"\\s+width=\"(.+)\"\\s+height=\"(.+)\" />";
            MatchCollection matchs = Regex.Matches(html, regImage);
            WebClient wcdown = new WebClient();
            foreach (Match  item in matchs)
            {
                if (item.Success)
                {   //获取图片相对路径
                    string path = item.Groups[1].Value;
                    Console.WriteLine(path);
                    string imgpath = "http://www.qqjay.com" + path;
                    wcdown.DownloadFile(imgpath,@"D:\课程资源\图片\"+Path.GetFileName(imgpath));
                }
                
            }
            Console.WriteLine("文件下载成功!!");
            Console.ReadKey();

        }
    }
}

上个美女玩玩



热点排行