private void Parse(ParserInfo info) { if (Actions.ContainsKey(info.type)) { ThreadsCount++; if (Actions[info.type](info) && ParsingSuccess != null) { ParsingSuccess(info.url, null); } } }
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); } }
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); } }
public static void Add(ParserInfo info) { Instance.queue.Enqueue(info); }