コード例 #1
0
        public static void DownloadActreeAvator()
        {
            int  index        = 1;
            bool contiune     = true;
            var  folderPrefix = @"G:\Github\AllInOneAV\Setting\avator\";
            var  url          = "https://www.javbus.com/actresses/";
            var  cc           = JavBusDownloadHelper.GetJavBusCookie();

            while (contiune)
            {
                var content = HtmlManager.GetHtmlContentViaUrl(url + index++, "utf-8", false, cc);

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

                    string xpath   = "//a[@class='avatar-box text-center']";
                    string imgPath = "/img";

                    HtmlNodeCollection nodes = htmlDocument.DocumentNode.SelectNodes(xpath);

                    foreach (var node in nodes)
                    {
                        var img = node.ChildNodes[1].ChildNodes[1];

                        var src   = img.Attributes["src"].Value;
                        var title = img.Attributes["title"].Value;

                        if (!string.IsNullOrEmpty(src) && !string.IsNullOrEmpty(title))
                        {
                            var tempFolder = folderPrefix + title[0] + "\\";
                            if (!Directory.Exists(tempFolder))
                            {
                                Directory.CreateDirectory(tempFolder);
                            }

                            DownloadHelper.DownloadFile(src, tempFolder + title + ".jpg");
                            Console.WriteLine($"下载第 {index - 1} 页,{title} 的头像");
                        }
                    }
                }
                else
                {
                    contiune = false;
                }
            }
        }
コード例 #2
0
        async static void DoJob(string arg, int jobId, ScanParameter parameter = null)
        {
            if (parameter == null)
            {
                await StartJavRefresh("", arg, OutputJavRefresh);
            }
            else
            {
                models = JavBusDownloadHelper.GetJavbusAVList(parameter.StartingPage.FirstOrDefault(), parameter.PageSize, parameter.IsAsc);
            }

            ScanDataBaseManager.SetScanJobFinish(jobId, -1, models.Count);

            await Task.Run(() => UpdateRefreshUi(jobId));

            IsFinish = false;
        }