Exemplo n.º 1
0
        private static void FaviScan(List <string> urls)
        {
            ScanDataBaseManager.DeleteFaviScan();

            Parallel.ForEach(urls, new ParallelOptions {
                MaxDegreeOfParallelism = 10
            }, url =>
            {
                var htmlRes = JavCookieContanierHelper(url);

                if (htmlRes.Success)
                {
                    HtmlDocument htmlDocument = new HtmlDocument();
                    htmlDocument.LoadHtml(htmlRes.Content);

                    var titlePath = "//div[@class='boxtitle']";

                    var titleNode = htmlDocument.DocumentNode.SelectSingleNode(titlePath);

                    if (titleNode != null)
                    {
                        var textArray = titleNode.InnerHtml.Trim().Split(' ');

                        var category = "";
                        var name     = textArray[0].Replace("&quot;", "");

                        if (textArray[1] == "所执导的影片")
                        {
                            category = "director";
                        }
                        else if (textArray[1] == "识别码搜寻结果")
                        {
                            category = "prfix";
                        }
                        else if (textArray[1] == "相关的影片")
                        {
                            category = "category";
                        }
                        else
                        {
                            category = "actress";
                        }

                        FaviScan fs = new FaviScan
                        {
                            Url      = url,
                            Name     = name,
                            Category = category
                        };

                        Console.WriteLine("扫描 " + url + " 分类 " + category + " 名称 " + name);
                        ScanDataBaseManager.InsertFaviScan(fs);
                    }
                }
            });
        }