C # Implementation Crawl HD beauty sister paper pictures
The code is as follows:
private void Dofetch (int pagenum)
{
ThreadPool.QueueUserWorkItem (_ =
{
HttpWebRequest request = (HttpWebRequest) webrequest.create ("
Beauty photography? 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 = @ "]*?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;
}
The above is the whole content of this article, we can freely expand Oh, you know, I hope you can like.
In addition to the Declaration,
Running GuestArticles are original, reproduced please link to the form of the address of this article
C # Implementation Crawl HD beauty sister paper pictures
This address: http://www.paobuke.com/develop/c-develop/pbk23114.html
Related content. NET C # using zxing to generate, identify QR codes/Barcodes C # Implement polling algorithm instance code c#3.0 use EventLog class to write Windows event log methods C # virtual function Usage Instance analysis
How do you describe C # in 4 deep-copy methods in C #? D??? 3?? èí?tê?? Ò?°2x°êμ?? ′ú???? Íc# How to operate the IIS root lock system in C # multithreaded programming (III)
C # Implementation Crawl HD beauty sister paper pictures