using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AVSORTER;
using System.Text.RegularExpressions;
using HtmlAgilityPack;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
namespace Gets
{
public class Arzon : AVSORTER.IGetable, ICloneable
{
Uri uri;
MyWebClient wc;
///
/// 构造函数
///
/// 决定是否初始化Cookie,初始化Cookie需要耗费时间并且需要联网,或者根据需要手动调用CookiesInit()方法
public Arzon(bool IsInit)
{
wc = new MyWebClient();
if (IsInit)
{
CookiesInit();
}
}
public void CookiesInit()
{
const string url = @"http://www.arzon.jp/index.php?action=adult_customer_agecheck&agecheck=1";//&redirect=http%3A%2F%2Fwww.arzon.jp%2F";
uri = new Uri(url);
wc.DownloadDataCompleted += wc_DownloadDataCompleted;
wc.DownloadDataAsync(uri, "init");
}
public event EventHandler InitCompleted;
void wc_DownloadDataCompleted(object sender, System.Net.DownloadDataCompletedEventArgs e)
{
if ((e.UserState as string) == "init")
{
if (e.Error==null)
{
this.IsInitCompleted = true;
if (this.InitCompleted != null)
{
this.InitCompleted(this, new EventArgs());
}
}
}
}
public bool IsInitCompleted { get; set; }
public List Query(string fcode)
{
Uri u = urlCombine(fcode);
return PageParse(u);
}
private List PageParse(Uri u)
{
HtmlAgilityPack.HtmlDocument doc = new HtmlDocument();
doc.LoadHtml(wc.GetHTML(u));
//doc.DocumentNode.SelectNodes("//li[@class='saledate']/span")[3].InnerText
var listitems = doc.DocumentNode.SelectNodes("//div[@id='listitem']/table/tr/td/div[@class='data']/ul[1]/li[2]");
var htmnode = doc.DocumentNode.SelectSingleNode("//div[@class='autopagerize_page_element']");
if (htmnode == null)
{
//查无此片
return new List();
}
string htm = htmnode.InnerHtml;
List l = new List();
//