/// <summary> /// 执行注入Cookie的操作 /// </summary> /// <param name="spider">爬虫</param> /// <param name="pauseBeforeInject">注入Cookie前是否先暂停爬虫</param> public virtual void Inject(ISpider spider, bool pauseBeforeInject = true) { if (pauseBeforeInject) { spider.Pause(() => { foreach (Cookie cookie in GetCookies(spider)) { spider.AddCookie(cookie); } Logger.AllLog(spider.Identity, "Inject cookies success.", LogLevel.Info); spider.Contiune(); }); } else { foreach (Cookie cookie in GetCookies(spider)) { spider.AddCookie(cookie); } Logger.AllLog(spider.Identity, "Inject cookies success.", LogLevel.Info); } }