/// <summary> /// 从程序集加载UrlExtractor类型数组,失败时返回NULL /// </summary> /// <param name="assembly">程序集</param> /// <returns>UrlExtractor[]</returns> public static UrlExtractor[] LoadUrlExtractors(Assembly assembly, params object[] args) { Type[] types = LoadTypes(assembly, null, typeof(UrlExtractor)); List <UrlExtractor> list = new List <UrlExtractor>(); if (types.Length < 1) { return(null); } for (int i = 0; i < types.Length; i++) { UrlExtractor item = _typeToInstance(types[0], args) as UrlExtractor; if (null != item) { list.Add(item); } } UrlExtractor[] array = new UrlExtractor[list.Count]; list.CopyTo(array); return(array); }
protected SpiderSetting(SerializationInfo info, StreamingContext context) { this.name = info.GetString("name"); this.startUrl = info.GetValue("startUrl", typeof(StartUrl)) as StartUrl; this.maxDepth = info.GetInt16("maxDepth"); this.allowRedirect = info.GetBoolean("allowRedirect"); this.requestTimeout = info.GetInt32("requestTimeout"); this.iOTimeout = info.GetInt32("iOTimeout"); this.readBufferSize = info.GetInt32("readBufferSize"); this.crawlThreads = info.GetInt16("crawlThreads"); this.processThreads = info.GetInt16("processThreads"); this.proxy = info.GetValue("proxy", typeof(IWebProxy)) as IWebProxy; this.userAgent = info.GetString("userAgent"); this.referer = info.GetString("referer"); this.cookies = info.GetValue("cookies", typeof(CookieCollection)) as CookieCollection; this.requestEncoding = info.GetValue("requestEncoding", typeof(Encoding)) as Encoding; this.urlExtractor = info.GetValue("urlExtractor", typeof(UrlExtractor)) as UrlExtractor; this.contentHandlers = info.GetValue("contentHandlers", typeof(ContentHandlerCollection)) as ContentHandlerCollection; this.logger = info.GetValue("logger", typeof(ILogger)) as ILogger; this.memLimitSize = info.GetInt32("memLimitSize"); this.depositePath = info.GetString("depositePath"); this.speedMode = (SpeedModes)info.GetValue("speedMode", typeof(SpeedModes)); }
protected SpiderSetting(SerializationInfo info, StreamingContext context) { this.name = info.GetString("name"); this.startUrl = info.GetValue("startUrl", typeof(StartUrl)) as StartUrl; this.maxDepth = info.GetInt16("maxDepth"); this.allowRedirect = info.GetBoolean("allowRedirect"); this.requestTimeout = info.GetInt32("requestTimeout"); this.iOTimeout = info.GetInt32("iOTimeout"); this.readBufferSize = info.GetInt32("readBufferSize"); this.crawlThreads = info.GetInt16("crawlThreads"); this.processThreads = info.GetInt16("processThreads"); this.proxy = info.GetValue("proxy", typeof(IWebProxy)) as IWebProxy; this.userAgent = info.GetString("userAgent"); this.referer = info.GetString("referer"); this.cookies = info.GetValue("cookies", typeof(CookieCollection)) as CookieCollection; this.requestEncoding = info.GetValue("requestEncoding", typeof(Encoding)) as Encoding; this.urlExtractor = info.GetValue("urlExtractor", typeof(UrlExtractor)) as UrlExtractor; this.contentHandlers = info.GetValue("contentHandlers", typeof(ContentHandlerCollection)) as ContentHandlerCollection; this.logger = info.GetValue("logger", typeof(ILogger)) as ILogger; this.memLimitSize = info.GetInt32("memLimitSize"); this.depositePath = info.GetString("depositePath"); this.speedMode = (SpeedModes)info.GetValue("speedMode",typeof(SpeedModes)); }