Esempio n. 1
0
        protected override IEnumDataPages_v1 <int, IHeaderData_v1> GetDataFromWeb(LoadDataFromWeb_v3 loadDataFromWeb)
        {
            XXElement xeSource          = new XXElement(loadDataFromWeb.GetXmlDocument().Root);
            string    url               = loadDataFromWeb.request.Url;
            ExtremeDown_HeaderPage data = new ExtremeDown_HeaderPage();

            data.sourceUrl       = url;
            data.loadFromWebDate = loadDataFromWeb.loadFromWebDate;
            data.id = ExtremeDown_LoadHeaderPagesManager.GetHeaderPageKey(url);

            data.urlNextPage = zurl.GetUrl(url, xeSource.XPathValue("//div[@class='navigation ignore-select']//a[starts-with(text(), 'Suivant')]/@href"));
            IEnumerable <XXElement>       xeHeaders = xeSource.XPathElements("//div[@id='dle-content']//div[@class='blockbox']");
            List <ExtremeDown_PostHeader> headers   = new List <ExtremeDown_PostHeader>();

            foreach (XXElement xeHeader in xeHeaders)
            {
                ExtremeDown_PostHeader header = new ExtremeDown_PostHeader();
                header.sourceUrl       = url;
                header.loadFromWebDate = loadDataFromWeb.loadFromWebDate;

                header.urlDetail = xeHeader.XPathValue(".//h2[@class='blocktitle']//a/@href");

                headers.Add(header);
            }
            data.postHeaders = headers.ToArray();
            return((IEnumDataPages_v1 <int, IHeaderData_v1>)data);
        }
Esempio n. 2
0
        public static void ClassInit(XElement xe)
        {
            //__useUrlCache = xe.zXPathValueBool("UseUrlCache", false);
            __useUrlCache    = xe.zXPathValue("UseUrlCache").zTryParseAs(false);
            __cacheDirectory = xe.zXPathValue("CacheDirectory");

            //__useMongo = xe.zXPathValueBool("UseMongo", __useMongo);
            __useMongo              = xe.zXPathValue("UseMongo").zTryParseAs(__useMongo);
            __mongoServer           = xe.zXPathValue("MongoServer", __mongoServer);
            __mongoDatabase         = xe.zXPathValue("MongoDatabase");
            __mongoCollectionName   = xe.zXPathValue("MongoCollection");
            __mongoDocumentItemName = xe.zXPathValue("MongoDocumentItemName");

            //IDocumentStore_new<int, ExtremeDown_HeaderPage> documentStore = null;
            IDocumentStore_v3 <int, IEnumDataPages_v1 <int, IHeaderData_v1> > documentStore = null;

            if (__useMongo)
            {
                //documentStore = new MongoDocumentStore_new<int, ExtremeDown_HeaderPage>(__mongoServer, __mongoDatabase, __mongoCollectionName, __mongoDocumentItemName);
                MongoDocumentStore_v3 <int, IEnumDataPages_v1 <int, IHeaderData_v1> > mongoDocumentStore = new MongoDocumentStore_v3 <int, IEnumDataPages_v1 <int, IHeaderData_v1> >(__mongoServer, __mongoDatabase, __mongoCollectionName, __mongoDocumentItemName);
                mongoDocumentStore.DefaultSort = "{ 'download.id': 1 }";
                //mongoDocumentStore.GetDataKey = headerPage => headerPage.id;
                mongoDocumentStore.GetDataKey  = headerPage => headerPage.GetKey();
                mongoDocumentStore.Deserialize = document => (IEnumDataPages_v1 <int, IHeaderData_v1>)BsonSerializer.Deserialize <ExtremeDown_HeaderPage>(document);
                documentStore = mongoDocumentStore;
            }

            __currentLoadHeaderPagesManager = new ExtremeDown_LoadHeaderPagesManager(new ExtremeDown_LoadHeaderPageFromWebManager(GetUrlCache()), documentStore);
        }