private void addPageType(String pageUrl) { mCarTypeList.Clear(); HtmlDocument htmlDocument = new HtmlWeb().Load(WebConstants.BASE_URL + pageUrl); HtmlNodeCollection typeNodes = htmlDocument.DocumentNode.SelectNodes(WebConstants.TYPE_NODE); if (typeNodes != null) { foreach (HtmlNode tempNode in typeNodes) { HtmlNode typeNode = HtmlNode.CreateNode(tempNode.OuterHtml); CarType carType = new CarType(mCarFactory); HtmlNode nameNode = HtmlNode.CreateNode(typeNode.SelectSingleNode(WebConstants.TYPE_NAME).OuterHtml); carType.Name = nameNode.SelectSingleNode(WebConstants.LINK_HREF).InnerText; HtmlNode imageNode = HtmlNode.CreateNode(typeNode.SelectSingleNode(WebConstants.TYPE_IMAGE).OuterHtml); carType.ImageUrl = imageNode.SelectSingleNode(WebConstants.IMAGE_SRC).Attributes[WebConstants.SRC].Value; new Thread(new TypeImageDownloadTask(carType).Download).Start(); mCarTypeList.Add(carType); } } String priceUrl = pageUrl.Replace(WebConstants.PHOTO, WebConstants.PRICE); setPrice(priceUrl); }
public TypeImageDownloadTask(CarType carType) { mFilePath = Path.Combine(BASE_FILE_PATH, TYPE_DIR, PINYIN_DIR); //carType.CarFactory.CarBrand.Name, carType.CarFactory.Name); mFileName = Path.Combine(mFilePath, PinYinConverter.Get(carType.CarFactory.Name + "_" + carType.Name) + IMAGE_POSTFIX); carType.ImagePath = Path.Combine(Environment.CurrentDirectory, mFileName); initFile(); mUrl = carType.ImageUrl; }