c#實現抓取高清美女妹紙圖片
c#實現抓取高清美女妹紙圖片
代碼如下:
private void DoFetch(int pageNum)
{
ThreadPool.QueueUserWorkItem(_ =>
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(”
美女攝影?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<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;
}
以上就是本文的全部內容了,大家可以自由擴展哦,你懂得,希望大家能夠喜歡。
除聲明外,跑步客文章均為原創,轉載請以鏈接形式標明本文地址c#實現抓取高清美女妹紙圖片
本文地址: http://www.paobuke.com/develop/c-develop/pbk23114.html
相關內容
.NET C#利用ZXing生成、識別二維碼/條形碼c# 實現輪詢算法實例代碼C#3.0使用EventLog類寫Windows事件日誌的方法C#虛函數用法實例分析C#中4種深拷貝方法介紹C#?D???3??èí?tê?·?ò?°2×°êμ??′ú??·??íc#操作iis根目錄的方法C#多線程編程中的鎖系統(三)
c#實現抓取高清美女妹紙圖片