private async void btnMagnet_Click(object sender, EventArgs e) { lbxMagnet.Items.Clear(); magnets.Clear(); if (lbxNum.SelectedIndex != -1) { string magnetKeyword = Avers[lbxNum.SelectedIndex].Num; string sukebei_url = @"https://sukebei.nyaa.si/?f=0&c=0_0&q=" + magnetKeyword; HtmlDocument doc = await ArzonHttp.GetHtmldocAsync(sukebei_url); if (doc != null) { HtmlNodeCollection nodes = doc.DocumentNode.SelectNodes(@"//tbody/tr"); if (nodes != null) { foreach (var node in nodes) { Magnet magnet = new Magnet(); magnet.SetInfo(node); magnets.Add(magnet); } nodes.Clear(); foreach (var m in magnets) { lbxMagnet.Items.Add(m.title); } } else { MessageBox.Show("未搜索到结果", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("网络连接超时,请配置代理", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("请在左侧列表选择番号", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public async Task GetInfoAsync(string url) { this.Animeurl = url; HtmlDocument doc = await ArzonHttp.GetHtmldocAsync(url); if (doc != null) { //获取封面 string Imageurl = doc.DocumentNode.SelectSingleNode("//a[@data-lightbox='jacket1']").GetAttributeValue("href", "未找到"); Imageurl = "https:" + Imageurl; var task = ArzonHttp.GetImageAsync(Imageurl, this.Animeurl); //获取Title this.Title = doc.DocumentNode.SelectSingleNode(@"//h1").InnerText; //获取简介 try { this.Introduction = doc.DocumentNode.SelectSingleNode(@"//div[@class='item_text']").GetDirectInnerText(); Match introductionMc = Regex.Match(this.Introduction, @"\S+[\s\S]+\S+"); Introduction = introductionMc.Value; } catch { } //获取Maker try { this.Maker = doc.DocumentNode.SelectSingleNode(@"//table[@class='item']/tr[1]/td[2]/a").InnerText; } catch { } //获取Label try { this.MakerLabel = doc.DocumentNode.SelectSingleNode(@"//table[@class='item']/tr[2]/td[2]/a").InnerText; } catch { } //获取Release try { this.Release = doc.DocumentNode.SelectSingleNode(@"//table[@class='item']/tr[3]/td[2]").InnerText; Match releaseMc = Regex.Match(this.Release, @"\d{4}/\d{2}/\d{2}"); Release = releaseMc.Value; } catch { } //获取Runtime try { Runtime = doc.DocumentNode.SelectSingleNode(@"//table[@class='item']/tr[4]/td[2]").InnerText; Match runtimeMc = Regex.Match(this.Runtime, @"\d+分"); Runtime = runtimeMc.Value; } catch { } //获取Num try { Num = doc.DocumentNode.SelectSingleNode(@"//table[@class='item']/tr[5]/td[2]").InnerText; Match numMc = Regex.Match(this.Num, @"\S+"); Num = numMc.Value; } catch { } //获取Tag try { Tag = doc.DocumentNode.SelectSingleNode(@"//table[@class='item']/tr[6]/td[2]/a").InnerText; Match tagMc = Regex.Match(this.Tag, @"\S+"); Tag = tagMc.Value; } catch { } this.Poster = await task; } }
public async Task GetInfoAsync(string url) { //获取item_url this.Itemurl = url; //请求页面 HtmlDocument doc = await ArzonHttp.GetHtmldocAsync(url); if (doc != null) { //获取封面 this.Imageurl = doc.DocumentNode.SelectSingleNode("//a[@data-lightbox='jacket1']").GetAttributeValue("href", "未找到"); this.Imageurl = "https:" + this.Imageurl; var task = ArzonHttp.GetImageAsync(this.Imageurl, this.Itemurl); //获取Title HtmlNode titleNode = doc.DocumentNode.SelectSingleNode("//h1"); this.Title = titleNode.InnerText; //获取简介 try { this.Introduction = doc.DocumentNode.SelectSingleNode(@"//div[@class='item_text']").GetDirectInnerText(); Match introductionMc = Regex.Match(this.Introduction, @"\S+[\s\S]+\S+"); this.Introduction = introductionMc.Value; } catch { } //获取Actor,多名 try { HtmlNodeCollection actornodes = doc.DocumentNode.SelectNodes(@"//table[@class='item']/tr[1]/td[2]/a"); for (int i = 0; i < actornodes.Count; i++) { if (i == 0) { this.Actor = actornodes[i].InnerText; } else { this.Actor = this.Actor + "," + actornodes[i].InnerText; } } } catch { } //获取Maker try { this.Maker = doc.DocumentNode.SelectSingleNode(@"//table[@class='item']/tr[2]/td[2]/a").InnerText; } catch { } //获取MakerLabel try { this.MakerLabel = doc.DocumentNode.SelectSingleNode(@"//table[@class='item']/tr[3]/td[2]/a").InnerText; } catch { } //获取Series try { this.Series = doc.DocumentNode.SelectSingleNode(@"//table[@class='item']/tr[4]/td[2]/a").InnerText; } catch { } //获取Director try { this.Director = doc.DocumentNode.SelectSingleNode(@"//table[@class='item']/tr[5]/td[2]/a").InnerText; } catch { } //获取Release try { this.Release = doc.DocumentNode.SelectSingleNode(@"//table[@class='item']/tr[6]/td[2]").InnerText; Match releaseMc = Regex.Match(this.Release, @"\d{4}/\d{2}/\d{2}"); this.Release = releaseMc.Value; } catch { } //获取Runtime try { this.Runtime = doc.DocumentNode.SelectSingleNode(@"//table[@class='item']/tr[7]/td[2]").InnerText; Match runtimeMc = Regex.Match(this.Runtime, @"\d+分"); this.Runtime = runtimeMc.Value; } catch { } //获取Num try { this.Num = doc.DocumentNode.SelectSingleNode(@"//table[@class='item']/tr[8]/td[2]").InnerText; Match numMc = Regex.Match(this.Num, @"\S+\d+"); this.Num = numMc.Value; } catch { } //获取Tag try { this.Tag = doc.DocumentNode.SelectSingleNode(@"//table[@class='item']/tr[9]/td[2]/a").InnerText; Match tagMc = Regex.Match(this.Tag, @"\S+"); this.Tag = tagMc.Value; } catch { } Poster = await task; } }
private async void btnSearch_ClickAsync(object sender, EventArgs e) { pgbKeyword.Value = 0; lbxNum.Items.Clear(); Animes.Clear(); Avers.Clear(); pgbKeyword.Value = 25; Boolean IfRenewSuccess = await ArzonHttp.RenewCookie(); pgbKeyword.Value = 50; if (IfRenewSuccess) { string url = @"https://www.arzon.jp"; string keywords = txtSearch.Text; string search_url = @"https://www.arzon.jp//itemlist.html?t=&m=all&s=&q=" + keywords; HtmlDocument resultdoc = await ArzonHttp.GetHtmldocAsync(search_url); if (resultdoc != null) { HtmlNodeCollection nodes; nodes = resultdoc.DocumentNode.SelectNodes("//dl[@class='hentry']/dt/a"); if (nodes != null) { List <Task> infotasks = new List <Task>(); foreach (var node in nodes) { string item_url = url + node.GetAttributeValue("href", "未找到"); Aver aver = new Aver(); Task infotask = aver.GetInfoAsync(item_url); infotasks.Add(infotask); Avers.Add(aver); } pgbKeyword.Value = 75; Task t = Task.WhenAll(infotasks.ToArray()); await t; t.Dispose(); infotasks.Clear(); nodes.Clear(); int fail = 0; foreach (var Aver in Avers) { if (Aver.Title != "") { lbxNum.Items.Add(Aver.Num); } else { fail++; } } if (fail != 0) { MessageBox.Show(fail.ToString() + "个信息获取失败", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); } pgbKeyword.Value = 100; } else { MessageBox.Show("未搜索到结果,请重新输入关键字", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); pgbKeyword.Value = 0; } } else { MessageBox.Show("获取搜索结果超时,请尝试使用http代理", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); pgbKeyword.Value = 0; } } else { MessageBox.Show("Cookie更新失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); pgbKeyword.Value = 0; } }