Exemple #1
0
 private void Parse(ParserInfo info)
 {
     if (Actions.ContainsKey(info.type))
     {
         ThreadsCount++;
         if (Actions[info.type](info) && ParsingSuccess != null)
         {
             ParsingSuccess(info.url, null);
         }
     }
 }
Exemple #2
0
        private static bool Parse2KLocal(ParserInfo info)
        {
            Uri test = new Uri(info.url);
            var host = test.Host;

            try
            {
                var dom = CQ.CreateFromUrl(info.url);
                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(false);
            }
        }
Exemple #3
0
        private static bool Parse2KGlobal(ParserInfo info)
        {
            Uri test = new Uri(info.url);
            var host = string.Format("{0}://{1}", test.Scheme, test.Host);

            try
            {
                var dom   = CQ.CreateFromUrl(info.url);
                var links = dom["h2 a"];

                foreach (var link in links)
                {
                    //urls.Add(host + link["href"]);
                    Parser.Add(new ParserInfo {
                        type = "local_2k", url = host + link["href"]
                    });
                }
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Exemple #4
0
 public static void Add(ParserInfo info)
 {
     Instance.queue.Enqueue(info);
 }