1. Time stamp converted to C # format time
/// <summary> ///time stamp to C # format time/// </summary> /// <param name= "TimeStamp" >UNIX timestamp format</param> /// <returns>C # format time</returns> PrivateDateTime GetTime (stringTimeStamp) {DateTime Dtstart= TimeZone.CurrentTimeZone.ToLocalTime (NewDateTime (1970,1,1)); LongLtime =Long. Parse (TimeStamp +"0000"); TimeSpan Tonow=NewTimeSpan (ltime); returnDtstart.add (Tonow); }
2. Get the Verification code
PublicImage getimg (stringURL) { if(string. Isnullorwhitespace (URL)) {URL=string. Format ("http://ms.baihe.com/checkcode/defaultImageService?0. {0}", DateTime.Now.Ticks); } Cookiecheckcode=""; varitem =NewHttpitem () {URL=URL,//Encoding = System.Text.Encoding.GetEncoding ("GBK"),Method ="Get", //Istolower = False,Expect100continue =false,//agent, use this .Cookie =_cookie, Timeout=100000, Readwritetimeout=30000, useragent="mozilla/5.0 (Windows NT 6.1; WOW64; rv:28.0) gecko/20100101 firefox/28.0", ContentType="text/html", Resulttype=Resulttype.byte}; varresult =http. Gethtml (item); if(result.) Cookie! =NULL) Cookiecheckcode+ = result. Cookie.startswith ("Phpsessid") ? Result. Cookie.substring (result. Cookie.indexof (',') +1): result. Cookies; returnbytearraytoimage (result. Resultbyte); } PrivateImage ByteArrayToImage (byte[] Bytes) { using(varms =NewMemoryStream (Bytes)) { returnBitmap.fromstream (MS,true); } }
3. The regular table uses the class
Regex re =NewRegex (@"&uid= (\d+) \ "" Class=\ "" yellow\ "" > (. +) </a>", Regexoptions.none); MatchCollection MC=Re. Matches (resulthtml. Html); varList =NewList<user>(); foreach(Match matchinchMC) {varUID = match. groups[1]. Value; varNick = match. groups[2]. Value; List. ADD (NewUser {uid = uid, nickname =Nick}); }
4. Get time
Public Long Gettimelikejs () { varnew DateTime (197011); var t = (DateTime.Now.ToUniversalTime ()- st); return (long) t.totalmilliseconds; }
5. Another thread to operate the main thread of the control
this. Invoke (Action)delegate() { this" login succeeded "; });
Code to be used for crawler software development