public void Add(TaskGroup_GetUrlsByKeywords_OneData d)
 {
     if (data != null)
     {
         data.Add(d);
     }
 }
Ejemplo n.º 2
0
        public override object OneTask_Do(object data)
        {
            if (data == null || !(data is string))
            {
                return(null);
            }
            string strKeyword = (string)data;
            string strUA      = GlobalVar.Instance.uaList.GetUA(globalSetting.UAType);
            TaskGroup_GetUrlsByKeywords_Data list = new TaskGroup_GetUrlsByKeywords_Data();

            //GlobalVar.Instance.logger.Debug("DO BEGIN");
            if (this.setting.IsUseBaiduSearch)
            {
                List <string> result = BaiduSearch(strKeyword, strUA);
                result = result.Distinct().ToList();
                if (result != null && result.Count > 0)
                {
                    list.Status = TaskStatus.eTaskStatus_Finish_Suceessed;
                    foreach (string url in result)
                    {
                        TaskGroup_GetUrlsByKeywords_OneData d = new TaskGroup_GetUrlsByKeywords_OneData(url);
                        d.Keyword   = strKeyword;
                        d.Successed = true;
                        d.eSource   = GetUrlsSource.eGetUrlsSource_Baidu;
                        list.Add(d);
                    }
                }
            }
            //GlobalVar.Instance.logger.Debug($"DO END [{list.Count}]");
            Thread.Sleep(globalSetting.IntervalTimeMS);

            // 数据保护
            if (list.Count() <= 0)
            {
                TaskGroup_GetUrlsByKeywords_OneData d = new TaskGroup_GetUrlsByKeywords_OneData("");
                d.Keyword   = strKeyword;
                d.eSource   = GetUrlsSource.eGetUrlsSource_Unknown;
                d.Successed = false;
                list.Add(d);

                list.Status = TaskStatus.eTaskStatus_Finish_Error;
            }

            return(list);
        }