protected override void _LoadDocumentFromWeb(string file = null, bool reload = false, bool loadImage = false) { Gesat_LoadHeaderFromWeb loadFromWeb = new Gesat_LoadHeaderFromWeb(_url, file, reload, loadImage); loadFromWeb.Load(); _data = loadFromWeb.Data; }
public bool MoveNext() { while (true) { if (_enumerator == null) { Gesat_LoadHeader load = new Gesat_LoadHeader(_url); load.Load(_reload, _loadImage); _headerPage = load.Data; _enumerator = _headerPage.headerCompanies.AsEnumerable <Gesat_HeaderCompany>().GetEnumerator(); } if (_enumerator.MoveNext()) { return(true); } if (_nbPage == _maxPage && _maxPage != 0) { return(false); } _url = _headerPage.urlNextPage; if (_url == null) { return(false); } _headerPage = null; _enumerator = null; _nbPage++; } }
protected override void Load() { Gesat_LoadHeader2 load = new Gesat_LoadHeader2(Url); load.Load(Reload, LoadImage); _headerPage = load.Data; _enumerator = _headerPage.headerCompanies.AsEnumerable <Gesat_HeaderCompany>().GetEnumerator(); }
protected override void SetXml(XElement xelement) { XXElement xeSource = new XXElement(xelement); _data = new Gesat_HeaderPage(); // <div class="PAGENAVIGLIST"> // <a href="/Gesat/EtablissementList-10-10.html" title="page suivante">></a> _data.urlNextPage = GetUrl(xeSource.XPathValue("//div[@class='PAGENAVIGLIST']//a[@title='page suivante']/@href")); // <div class="ETABLISSEMENT STAR-1 ODD"> <div class="ETABLISSEMENT STAR-0 ODD"> <div class="ETABLISSEMENT STAR-1 EVEN"> IEnumerable <XXElement> xeHeaders = xeSource.XPathElements("//div[starts-with(@class, 'ETABLISSEMENT STAR-')]"); List <Gesat_HeaderCompany> headers = new List <Gesat_HeaderCompany>(); foreach (XXElement xeHeader in xeHeaders) { Gesat_HeaderCompany header = new Gesat_HeaderCompany(); header.sourceUrl = _url; header.loadFromWebDate = DateTime.Now; //<span class="NOM"><a title="ESAT BETTY LAUNAY-MOULIN VERT" href="/Gesat/Hauts-de-Seine,92/Bois-Colombes,35494/esat-betty-launay-moulin-vert-competences-et-handicap-92,e1837/">ESAT BETTY LAUNAY-MOULIN VERT</a></span> //_header.companyName = xeHeader.ExplicitXPathValue(".//span[@class='NOM']//a//text()"); XXElement xe = xeHeader.XPathElement(".//span[@class='NOM']//a"); if (xe != null) { header.url = GetUrl(xe.ExplicitXPathValue("@href")); //header.name = xe.ExplicitXPathValue(".//text()", _trimFunc1); header.name = _trimFunc1(xe.ExplicitXPathValue(".//text()")); } //<span class="VILLE">E.S.A.T.<br />Bois-Colombes (92)</span> xe = xeHeader.XPathElement(".//span[@class='VILLE']"); if (xe != null) { //IEnumerator<string> texts = xe.DescendantTextList().GetEnumerator(); IEnumerator <string> texts = xe.DescendantTexts().GetEnumerator(); if (texts.MoveNext()) { header.type = texts.Current.Trim(); } else { Trace.CurrentTrace.WriteLine("error companyType not found"); } if (texts.MoveNext()) { header.location = texts.Current.Trim(); } else { Trace.CurrentTrace.WriteLine("error companyLocation not found"); } } // <span class="TELEPHONE">01 47 86 11 48</span> //header.phone = xeHeader.ExplicitXPathValue(".//span[@class='TELEPHONE']//text()", _trimFunc1); header.phone = _trimFunc1(xeHeader.ExplicitXPathValue(".//span[@class='TELEPHONE']//text()")); //<img info_bulle="Signataire de la charte Ethique et Valeurs" border="0" alt="/images/bullesGesat/pictoCharte.png" src="/images/bullesGesat/pictoCharte.png" style=" border: 0;" /> //<img info_bulle="Lauréat des trophées HandiResponsables 2013" border="0" alt="/images/bullesGesat/LAURIERS-OR-2013.png" src="/images/bullesGesat/LAURIERS-OR-2013.png" style=" border: 0;" /> //header.infos = xeHeader.XPathValues(".//img/@info_bulle", _trimFunc1); header.infos = xeHeader.XPathValues(".//img/@info_bulle").Select(_trimFunc1).ToArray(); //_header.SetInfo(xeHeader.XPathValues(".//img/@info_bulle")); headers.Add(header); } _data.headerCompanies = headers.ToArray(); }