c#实现抓取高清美女妹纸图片

本文给大家分享的是一则使用c#实现抓取网络高清美女妹纸图片的代码,这么好的东西,当然不能独享,推荐给小伙伴们。

c#实现抓取高清美女妹纸图片

复制代码 代码如下:

private void DoFetch(int pageNum)
        {
            ThreadPool.QueueUserWorkItem(_ =>
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://me2-sex.lofter.com/tag/美女摄影?page=" + pageNum);
                request.Credentials = System.Net.CredentialCache.DefaultCredentials;
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                if (response.StatusCode == HttpStatusCode.OK)
                {
                    using (StreamReader sr = new StreamReader(response.GetResponseStream()))
                    {
                        List links = FetchLinksFromSource(sr.ReadToEnd());
                        Console.WriteLine("=========================" + pageNum + "fatch END==========================");
                    }
                }
            });
        }
        private List FetchLinksFromSource(string htmlSource)
        {
            List links = new List();
            string regexImgSrc = @"]*?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;
        }

以上就是本文的全部内容了,大家可以自由扩展哦,你懂得,希望大家能够喜欢。

以上就是c#实现抓取高清美女妹纸图片的详细内容,更多请关注0133技术站其它相关文章!

赞(0) 打赏
未经允许不得转载:0133技术站首页 » 其他教程