예제 #1
0
파일: Class1.cs 프로젝트: Hirep/PicCapLib
        public static void get_Bing_Img()
        {
            WebClient webClient = new WebClient();
            var page = webClient.DownloadString("http://www.bing.com/");

            String matchStart = "g_img={url:'";
            String matchEnd = "',id:'bgDiv'";
            ImageSource imgSrc = new ImageSource(page, matchStart, matchEnd);
            String link = "http://www.bing.com" + imgSrc.getImageSource();
            DateTime today = DateTime.Today;
            var name = Directory.GetCurrentDirectory() + "\\Bing\\BING-" + today.ToString("dd-MM-yyyy")+".jpg";

            try
            {
                webClient.DownloadFile(link, name);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
예제 #2
0
파일: Class1.cs 프로젝트: Hirep/PicCapLib
        public static void get_NASA_APOD()
        {
            WebClient webClient = new WebClient();
            var page = webClient.DownloadString("http://apod.nasa.gov/apod/astropix.html");

            String matchStart = "<a href=\"image";
            String matchEnd = "\">"+ '\n' + "<IMG SRC";
            ImageSource imgSrc = new ImageSource(page, matchStart, matchEnd);
            String link = "http://apod.nasa.gov/apod/image" + imgSrc.getImageSource();
            DateTime today = DateTime.Today;
            var name = Directory.GetCurrentDirectory() + "\\APOD\\NASA-" + today.ToString("dd-MM-yyyy") + ".jpg";

            try
            {
                webClient.DownloadFile(link, name);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }