最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

c#實(shí)現(xiàn)抓取高清美女妹紙圖片

 更新時(shí)間:2015年03月11日 16:14:19   投稿:hebedich  
本文給大家分享的是一則使用c#實(shí)現(xiàn)抓取網(wǎng)絡(luò)高清美女妹紙圖片的代碼,這么好的東西,當(dāng)然不能獨(dú)享,推薦給小伙伴們。

c#實(shí)現(xiàn)抓取高清美女妹紙圖片

復(fù)制代碼 代碼如下:

private void DoFetch(int pageNum)
        {
            ThreadPool.QueueUserWorkItem(_ =>
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create("                 request.Credentials = System.Net.CredentialCache.DefaultCredentials;
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                if (response.StatusCode == HttpStatusCode.OK)
                {
                    using (StreamReader sr = new StreamReader(response.GetResponseStream()))
                    {
                        List<Uri> links = FetchLinksFromSource(sr.ReadToEnd());
                        Console.WriteLine("=========================" + pageNum + "fatch END==========================");
                    }
                }
            });
        }
        private List<Uri> FetchLinksFromSource(string htmlSource)
        {
            List<Uri> links = new List<Uri>();
            string regexImgSrc = @"<img[^>]*?src\s*=\s*[""']?([^'"" >]+?)[ '""][^>]*?>";
            MatchCollection matchesImgSrc = Regex.Matches(htmlSource, regexImgSrc, RegexOptions.IgnoreCase | RegexOptions.Singleline);
            foreach (Match m in matchesImgSrc)
            {
                string href = m.Groups[1].Value;
                if (CheckIsUrlFormat(href))
                {
                    links.Add(new Uri(href));
                    Console.WriteLine(href);
                }
                else
                    continue;
                using (WebClient myWebClient = new WebClient())
                {
                    try
                    {
                        myWebClient.DownloadFile(new Uri(href), System.IO.Path.Combine(globePath, System.IO.Path.GetRandomFileName() + System.IO.Path.GetExtension(href)));
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            }
            return links;
        }

以上就是本文的全部?jī)?nèi)容了,大家可以自由擴(kuò)展哦,你懂得,希望大家能夠喜歡。

相關(guān)文章

最新評(píng)論

麻栗坡县| 林甸县| 安义县| 昭苏县| 江西省| 奉化市| 咸丰县| 齐河县| 克东县| 高唐县| 杭锦后旗| 漠河县| 张北县| 酒泉市| 苗栗市| 聂荣县| 淄博市| 太仓市| 镇远县| 开封市| 华池县| 兰西县| 黑水县| 通榆县| 永川市| 长岛县| 三原县| 潢川县| 兰州市| 明光市| 德江县| 洞头县| 乐清市| 新密市| 揭西县| 云龙县| 洮南市| 南陵县| 桂林市| 松潘县| 宁陕县|