public ActionResult ProductIndex(string search, int?page) { List <Product> productList = _db.Products.ToList(); ProductListItem productVM = new ProductListItem(); List <ProductListItem> productVMList = productList.Select(x => new ProductListItem { ProductName = x.ProductName, CategoryId = x.CategoryId, CategoryName = x.Category.CategoryName, Quantity = x.Quantity, Price = x.Price }).ToList(); HomeIndexViewModel model = new HomeIndexViewModel(); return(View(model.CreateModel(search, page, 10))); // return View(model.CreateModel()); //return View(productVMList); // //return View(_db.Products.ToList()); //} // *** use this code when database is null ***// //public ActionResult ProductInd() //{ // List<Product> productList = _db.Products.ToList(); // List<Product> orderedList = productList.OrderBy(prod => prod.ProductName).ToList(); // return View(orderedList); }
private static async void GetHtmlAsync() { var url = "https://www.ebay.com/sch/i.html?_nkw=nintendo+switch&_in_kw=1&_ex_kw=&_sacat=0&_udlo=&_udhi=&_ftrt=901&_ftrv=1&_sabdlo=&_sabdhi=&_samilow=&_samihi=&_sadis=15&_stpos=94040&_sargn=-1%26saslc%3D1&_salic=1&_sop=12&_dmd=1&_ipg=200"; var httpClient = new HttpClient(); var html = await httpClient.GetStringAsync(url); var htmlDocument = new HtmlDocument(); htmlDocument.LoadHtml(html); var ProductsHtml = htmlDocument.DocumentNode.Descendants("ul") .Where(node => node.GetAttributeValue("id", "") .Equals("ListViewInner")).ToList(); var ProductListItems = ProductsHtml[0].Descendants("li") .Where(node => node.GetAttributeValue("id", "") .Contains("item")).ToList(); Console.WriteLine(ProductListItems.Count() + " Listings"); Console.WriteLine(); foreach (var ProductListItem in ProductListItems) { //Listing ID Console.WriteLine("Listing ID: " + ProductListItem.GetAttributeValue("listingid", "")); //Product Name Console.WriteLine("Product Name: " + ProductListItem.Descendants("h3") .Where(node => node.GetAttributeValue("class", "") .Equals("lvtitle")).FirstOrDefault().InnerText.Replace("New listing", String.Empty).Replace("\n", String.Empty).Replace("\r", String.Empty).Replace("\t", String.Empty) ); //Product Price Console.WriteLine("Price: " + Regex.Match( ProductListItem.Descendants("li") .Where(node => node.GetAttributeValue("class", "") .Equals("lvprice prc")).FirstOrDefault().InnerText , @"\d+.\d+") ); //Listing Type Console.WriteLine("# of Bids or Buy it Now: " + ProductListItem.Descendants("li") .Where(node => node.GetAttributeValue("class", "") .Equals("lvformat")).FirstOrDefault().InnerText.Replace("\n", String.Empty).Replace("\r", String.Empty).Replace("\t", String.Empty) ); //Product URL Console.WriteLine("Product URL: " + ProductListItem.Descendants("a") .Where(node => node.GetAttributeValue("class", "") .Equals("vip")).FirstOrDefault().GetAttributeValue("href", "") ); Console.WriteLine(); } }
public void FromEntityList_should_return_empty_list_when_entity_list_is_null() { var productList = new ProductListItem().FromEntityList(null); Assert.That(productList, Is.Not.Null); Assert.That(productList.Any(), Is.False); }
private static async void GetHtmlAsync() { var url = "https://miami.craigslist.org/search/reb?min_price=2500&max_price=250000&availabilityMode=0&housing_type=6&sale_date=all+dates&lang=en&cc=gb"; var httpClient = new HttpClient(); var html = await httpClient.GetStringAsync(url); var htmlDocument = new HtmlDocument(); htmlDocument.LoadHtml(html); var ProductsHtml = htmlDocument.DocumentNode.Descendants("ul") .Where(node => node.GetAttributeValue("class", "") .Equals("rows")).ToList(); int i = 0; var ProductListItems = ProductsHtml[0].Descendants("li") .Where(node => node.GetAttributeValue("class", "") .Equals("result-row")).ToList(); foreach (var ProductListItem in ProductListItems) { Console.WriteLine(ProductListItem.Descendants("a") .Where(node => node.GetAttributeValue("class", "") .Contains("result-title")).FirstOrDefault().InnerText); } Console.WriteLine(); }
public async void GetNews(string user_input, int ResultNum) { // Getting news from DailyMail user_input.Replace(@" ", "+"); var url = "https://www.dailymail.co.uk/home/search.html?sel=site&size=" + ResultNum + "&searchPhrase=" + user_input + "&sort=relevant"; var httpclient = new HttpClient(); var html = await httpclient.GetStringAsync(url); var htmlDocument = new HtmlDocument(); string title, current_url; htmlDocument.LoadHtml(html); var ProductsHtml = htmlDocument.DocumentNode.Descendants("div").Where(node => node.GetAttributeValue("class", "").Equals("sch-res-content")).ToList(); Article[] article = new Article[ResultNum]; for (int i = 0; i < ResultNum; i++) { var ProductListItems = ProductsHtml[i].Descendants("h3").Where(node => node.GetAttributeValue("class", "").Contains("sch-res-title")).ToList(); foreach (var ProductListItem in ProductListItems) { title = System.Net.WebUtility.HtmlDecode(ProductListItem.InnerText); current_url = "https://www.dailymail.co.uk" + ProductListItem.Descendants("a").FirstOrDefault().GetAttributeValue("href", ""); article[i] = new Article(); article[i].Title = title; article[i].URL = current_url; //Console.WriteLine(i + 1 + ". " + title); //Console.WriteLine("Link: " + current_url); } } Articles = article; }
private static async void GetHTMLAsync(string link) { var url = link; var httpClient = new HttpClient(); var html = await httpClient.GetStringAsync(url); var htmlDocument = new HtmlDocument(); htmlDocument.LoadHtml(html); var Products = htmlDocument.DocumentNode.Descendants("ul") .Where(node => node.GetAttributeValue("id", "") .Equals("ListViewInner")).ToList(); var ProductListItems = Products[0].Descendants("li") .Where(node => node.GetAttributeValue("id", "") .Contains("item")).ToList(); foreach (var ProductListItem in ProductListItems) { Console.WriteLine(ProductListItem.GetAttributeValue("listingid", "")); Console.WriteLine(ProductListItem.Descendants("h3") .Where(node => node.GetAttributeValue("class", "") .Equals("lvtitle")).FirstOrDefault().InnerText.Trim('\r', '\t', '\n') ); Console.WriteLine(ProductListItem.Descendants("li") .Where(node => node.GetAttributeValue("class", "") .Equals("lvprice prc")).FirstOrDefault().InnerText.Trim('\r', '\t', '\n') ); Console.WriteLine(); } Console.WriteLine("This is made by RTG, all rights reserved!"); }
private static async void GetHtmlAsync() { var url = "https://www.ebay.com/sch/i.html?_from=R40&_trksid=p2322090.m570.l1313&_nkw=xbox+one&_sacat=0"; var httpClient = new HttpClient(); var html = await httpClient.GetStringAsync(url); var htmlDocument = new HtmlDocument(); htmlDocument.LoadHtml(html); var ProductsHtml = htmlDocument.DocumentNode.Descendants("ul") .Where(node => node.GetAttributeValue("class", "") .Equals("srp-results srp-list clearfix")).ToList(); var ProductListItems = ProductsHtml[0].Descendants("li") .Where(node => node.GetAttributeValue("data-view", "") .Contains("mi:1686|iid:")).ToList(); Console.WriteLine(ProductListItems.Count); foreach (var ProductListItem in ProductListItems) { //id Console.WriteLine(ProductListItem.GetAttributeValue("data-view", "")); //ProductName var productTitle = ProductListItem.Descendants("h3") .Where(node => node.GetAttributeValue("class", "") .Equals("s-item__title")).FirstOrDefault()?.InnerText.Trim('\r', '\n', '\t'); var productTitleHash = ProductListItem.Descendants("h3") .Where(node => node.GetAttributeValue("class", "") .Equals("s-item__title s-item__title--has-tags")).FirstOrDefault()?.InnerText.Trim('\r', '\n', '\t'); Console.WriteLine(productTitle ?? productTitleHash); //Price Console.WriteLine(ProductListItem.Descendants("span") .Where(node => node.GetAttributeValue("class", "") .Equals("s-item__price")).FirstOrDefault()?.InnerText); //Price Using regex Console.WriteLine( Regex.Match( ProductListItem.Descendants("span") .Where(node => node.GetAttributeValue("class", "") .Equals("s-item__price")).FirstOrDefault()?.InnerText , @"\d+.\d+") ); //url var productUrl = ProductListItem.Descendants("a") .Where(node => node.GetAttributeValue("class", "") .Equals("s-item__link")).FirstOrDefault()?.GetAttributeValue("href", ""); Console.WriteLine(productUrl); Console.WriteLine(); } }
public static SearchItemViewModel To(this ProductListItem item) { return(new SearchItemViewModel { Code = item.Code, Name = item.Name }); }
public void FromEntityList_should_return_empty_list_when_entity_list_contains_no_entities() { var productEntityList = new List <Product>(); var productList = new ProductListItem().FromEntityList(productEntityList); Assert.That(productList, Is.Not.Null); Assert.That(productList.Any(), Is.False); }
private void ItemFrame_Tapped(object sender, EventArgs e) { Frame frame = sender as Frame; int index = ItemStack.Children.IndexOf(frame); ProductListItem productListItem = productListVM.ProductList[index]; ProductDetailPage productDetailPage = new ProductDetailPage(productListItem.productId.ToString()); Navigation.PushModalAsync(productDetailPage); }
public void FromEntityList_should_map_properties_when_entity_list_contains_entities() { var productEntityList = Fakes.FakeProductList(); var productList = new ProductListItem().FromEntityList(productEntityList); Assert.That(productList, Is.Not.Null); Assert.That(productList.Any(), Is.True); Assert.That(productList[0].Name, Is.EqualTo(productEntityList.ToList()[0].Name)); }
private void ebayQuery(string product, string catagory, string minPrice, string maxPrice, string results, params string[] condition) { itemList = new List <Item>(); string url = "https://www.ebay.com/sch/i.html?_udlo=" + minPrice + "&_udhi=" + maxPrice + "&LH_ItemCondition=" + condition + "&_mPrRngCbx=1&_ipg=" + results + "&_from=R40&_trksid=p2045573.m570.l1313.TR0.TRC0.H0.TRS0&_nkw=" + product + "&_sacat=" + catagory + "&LH_Sold=1"; HtmlWeb page = new HtmlWeb(); var doc = page.Load(url); var ProductsHtml = doc.DocumentNode.Descendants("ul") .Where(node => node.GetAttributeValue("id", "") .Equals("ListViewInner")).ToList(); var ProductListItems = ProductsHtml[0].Descendants("li") .Where(node => node.GetAttributeValue("id", "") .Contains("item")).ToList(); string itemResults = doc.DocumentNode.SelectSingleNode("//*[@id='cbelm']/div[3]/h1/span[1]").InnerText; foreach (var ProductListItem in ProductListItems) { //ID string id = ProductListItem.GetAttributeValue("listingid", ""); //Title string title = ProductListItem.Descendants("h3") .Where(node => node.GetAttributeValue("class", "") .Equals("lvtitle")).FirstOrDefault().InnerText.Trim('\r', '\n', '\t').Replace("New listing", "").Replace("\r", "").Replace("\t", ""); //Price string price = Regex.Match(ProductListItem.Descendants("li") .Where(node => node.GetAttributeValue("class", "") .Equals("lvprice prc")).FirstOrDefault().InnerText.Trim('\r', '\n', '\t'), @"\d+.\d+").ToString(); //Bids string bids = ProductListItem.Descendants("li") .Where(node => node.GetAttributeValue("class", "") .Equals("lvformat")).FirstOrDefault().InnerText.Trim('\r', '\n', '\t').Replace("bids", "").Replace("Buy It Now", "").Replace("or Best Offer", "").Replace("bid", ""); //Links string link = ProductListItem.Descendants("a").FirstOrDefault().GetAttributeValue("href", ""); //Image string imgLink = ProductListItem.Descendants("img").FirstOrDefault().GetAttributeValue("src", ""); //create a new Item and add to the item list itemList.Add(new Item(title, id, price, link, bids, imgLink)); ListViewItem lvi = new ListViewItem(id); lvi.SubItems.Add(title); lvi.SubItems.Add(price); lvi.SubItems.Add(bids); lvi.SubItems.Add(link); lvData.Items.Add(lvi); } label1.Text = lvData.Items.Count.ToString(); lblItemResults.Text = "Total Results : " + itemResults; }
private static async void GetHtmlAsync() { var url = "https://www.ebay.co.uk/sch/i.html?_nkw=xbox+one&_in_kw=1&_ex_kw=&_sacat=0&_udlo=&_udhi=&_ftrt=901&_ftrv=1&_sabdlo=&_sabdhi=&_samilow=&_samihi=&_sadis=15&_stpos=CF434TP&_sargn=-1%26saslc%3D1&_salic=3&_sop=12&_dmd=1&_ipg=200"; var httpClient = new HttpClient(); var html = await httpClient.GetStringAsync(url); var htmlDocument = new HtmlDocument(); htmlDocument.LoadHtml(html); var ProductsHtml = htmlDocument.DocumentNode.Descendants("ul") .Where(node => node.GetAttributeValue("id", "") .Equals("ListViewInner")).ToList(); //displays all nodes with id in the list var ProductListItems = ProductsHtml[0].Descendants("li") .Where(node => node.GetAttributeValue("id", "") .Contains("item")).ToList();//thins down the information and isolates each id by item foreach (var ProductListItem in ProductListItems) { //id Console.WriteLine(ProductListItem.GetAttributeValue("listingid", "")); //Product name Console.WriteLine(ProductListItem.Descendants("h3") .Where(HtmlNode => HtmlNode.GetAttributeValue("class", "") .Equals("lvtitle")).FirstOrDefault().InnerText.Trim('\r', '\n', '\t') //gets the inner text of the element ); //Price Console.WriteLine( Regex.Match( ProductListItem.Descendants("li") .Where(HtmlNode => HtmlNode.GetAttributeValue("class", "") .Equals("lvprice prc")).FirstOrDefault().InnerText.Trim('\r', '\n', '\t') //trims return, newline and tab , @"\d+.\d+") //for some reason cant get this to work regex.match ); //Listing Type lvformat Console.WriteLine( ProductListItem.Descendants("li") .Where(HtmlNode => HtmlNode.GetAttributeValue("class", "") .Equals("lvformat")).FirstOrDefault().InnerText.Trim('\r', '\n', '\t') ); //url Console.WriteLine( ProductListItem.Descendants("a").FirstOrDefault().GetAttributeValue("href", "").Trim('\r', '\n', '\t')); Console.WriteLine(); } }
public ViewResult List(int page = 0, int perPage = 25, string orderBy = null, string asc = "true") { Tuple <IEnumerable <Product>, int> result = GetProductList(page, orderBy, asc, perPage); var productList = new ProductListItem().FromEntityList(result.Item1); var pagingDto = new PagingDTO { TotalItems = result.Item2, CurrentPage = page, PerPage = perPage, TotalPages = GetTotalPages(result.Item2, perPage) }; ViewBag.Paging = pagingDto; return(View(productList)); }
private async void Delete_Tapped(object sender, EventArgs e) { ProductListItem selectedItem = allList[productsIndex].ProductsList.First <ProductListItem>(x => x.ID == (int)((TappedEventArgs)e).Parameter); if (selectedItem != null && selectedItem.ID > 0 && await DisplayAlert("Delete", "Are you sure you want to delete " + selectedItem.DisplayName, "OK", "CANCEL")) { allList[productsIndex].ProductsList.Remove(selectedItem); resultImage.Source = null; Application.Current.Properties[App.Current.Resources["AllListsSource"].ToString()] = JsonConvert.SerializeObject(allList); await Application.Current.SavePropertiesAsync(); } }
public ActionResult <ProductListItem> Get(string id) { PD_S_PRODUCT Item = DBContext.PD_S_PRODUCT.FirstOrDefault(E => E.PRODUCT_CODE == id); if (Item == null) { throw new NotFoundException(string.Format("No product found with key: '{0}'", id)); } ProductListItem Result = new ProductListItem(Item); Result.LoadExtData(DBContext, Item); return(Result); }
private static async void GetHtmlAsync() { var url = "https://www.ebay.com/"; var httpClient = new HttpClient(); var html = await httpClient.GetAsync(url); string html2 = html.ToString(); var htmlDocument = new HtmlDocument(); htmlDocument.LoadHtml(html2); var ProductsHtml = htmlDocument.DocumentNode.Descendants("ul") .Where(node => node.GetAttributeValue("id", "") .Equals("ListViewInner")).ToList(); var ProductListItems = ProductsHtml[0].Descendants("li") .Where(node => node.GetAttributeValue("id", "") .Contains("item")).ToList(); foreach (var ProductListItem in ProductListItems) { //id Console.WriteLine(ProductListItem.GetAttributeValue("listingid", "")); //ProductName Console.WriteLine(ProductListItem.Descendants("h3") .Where(node => node.GetAttributeValue("class", "") .Equals("lvtitle")).FirstOrDefault().InnerText.Trim('\r', '\n', '\t').Replace("New listing", "").TrimStart() ); //ListingType Console.WriteLine( ProductListItem.Descendants("li") .Where(node => node.GetAttributeValue("class", "") .Equals("lvformat")).FirstOrDefault().InnerText.Trim('\r', '\n', '\t').Replace("or Best Offer", "0 bids").TrimEnd() ); //Url Console.WriteLine( ProductListItem.Descendants("a").FirstOrDefault().GetAttributeValue("href", "") ); Console.WriteLine(); } Console.WriteLine(); }
static async void GetHtmlAsync() { var url = "https://www.ebay.com/sch/i.html?_nkw=xbox+one&_in_kw=1&_ex_kw=&_sacat=0&LH_Complete=1&_udlo=&_udhi=&_samilow=&_samihi=&_sadis=15&_stpos=&_sargn=-1%26saslc%3D1&_salic=1&_sop=12&_dmd=1&_ipg=50"; var httpclient = new HttpClient(); var html = await httpclient.GetStringAsync(url); var htmlDocument = new HtmlDocument(); htmlDocument.LoadHtml(html); var ProductsHtml = htmlDocument.DocumentNode.Descendants("ul") .Where(node => node.GetAttributeValue("id", "") .Equals("ListViewInner")).ToList(); var ProductListItems = ProductsHtml[0].Descendants("li") .Where(node => node.GetAttributeValue("id", "") .Contains("item")).ToList(); Console.WriteLine(ProductListItems.Count()); Console.WriteLine(); foreach (var ProductListItem in ProductListItems) { //ID Console.WriteLine(ProductListItem.GetAttributeValue("listingid", "")); //ProductName Console.WriteLine(ProductListItem.Descendants("h3") .Where(node => node.GetAttributeValue("class", "") .Equals("lvtitle")).FirstOrDefault().InnerText.Trim('\r', '\n', '\t')); //Price Console.WriteLine(ProductListItem.Descendants("li") .Where(node => node.GetAttributeValue("class", "") .Equals("lvprice prc")).FirstOrDefault().InnerText.Trim('\r', '\n', '\t') ); //ListingType Console.WriteLine(ProductListItem.Descendants("li") .Where(node => node.GetAttributeValue("class", "") .Equals("lvformat")).FirstOrDefault().InnerText.Trim('\r', '\n', '\t') ); //URL Console.WriteLine( ProductListItem.Descendants("a").FirstOrDefault().GetAttributeValue("href", "") ); Console.WriteLine(); } }
static void Main(string[] args) { Console.OutputEncoding = Encoding.UTF8; Console.WriteLine("Введите название товара, который вас интересует: \n"); string input = Console.ReadLine(); Parser parser = new Parser($"https://www.olx.ua/list/q-{input}/"); HtmlAgilityPack.HtmlDocument htmlDoc = parser.LoadAndGetHtmlDocument(); parser.SetProductList("fixed offers breakword offers--top redesigned"); Console.WriteLine("У меня есть всё, если у тебя есть достаточно руппи\n"); try { foreach (var ProductListItem in parser.ProductListItems) { Console.WriteLine(ProductListItem.Descendants("h3") .Where(node => node.GetAttributeValue("class", "") .Equals("lheight22 margintop5")).FirstOrDefault().InnerText); Console.WriteLine(ProductListItem.Descendants("p") .Where(node => node.GetAttributeValue("class", "") .Equals("price")).FirstOrDefault().InnerText); } } catch (Exception e) { Console.WriteLine("Цена не указана"); } parser.SetProductList("fixed offers breakword redesigned"); try { foreach (var ProductListItem in parser.ProductListItems) { Console.WriteLine(ProductListItem.Descendants("h3") .Where(node => node.GetAttributeValue("class", "") .Equals("lheight22 margintop5")).FirstOrDefault().InnerText); Console.WriteLine(ProductListItem.Descendants("p") .Where(node => node.GetAttributeValue("class", "") .Equals("price")).FirstOrDefault().InnerText); } } catch (Exception e) { Console.WriteLine("Цена не указана"); } }
private void AddProductLists(StructureInfo structureInfo) { using (var batch = _dataService.CreateBatch()) { foreach (var productListLink in structureInfo.ProductCatalog.ProductListItems) { if (_productListService.Get <ProductList>(structureInfo.Id(productListLink.ProductListSystemId)) is object) { var item = new ProductListItem(structureInfo.Id(productListLink.BaseProductSystemId), structureInfo.Id(productListLink.ProductListSystemId)); foreach (var activeVariantSystemId in productListLink.ActiveVariantSystemIds) { item.ActiveVariantSystemIds.Add(structureInfo.Id(activeVariantSystemId)); } batch.Create(item); } } batch.Commit(); } }
//scrapes individual product URLs from an ebay category URL public async Task <List <string> > GetProductLinksFromeBayAsync(string urlToCheck) { var html = await _httpClient.GetStringAsync(urlToCheck); var htmlDocument = new HtmlDocument(); htmlDocument.LoadHtml(html); var ProductListItems = htmlDocument.DocumentNode.Descendants("li") .Where(node => node.GetAttributeValue("class", "") .Contains("s-item")).ToList(); List <string> productUrls = new List <string>(); foreach (var ProductListItem in ProductListItems) { var urls = ProductListItem.Descendants("a").FirstOrDefault().GetAttributeValue("href", ""); productUrls.Add(urls); } return(productUrls); }
public InvoiceDetail GetTransactionById(int id) { using (var ctx = new ApplicationDbContext()) { var invoice = ctx.Invoices.FirstOrDefault(t => t.InvoiceId == id && t.OwnerId == _userId); var query = ctx.InvoiceTransactions.Where(e => e.InvoiceId == id && e.OwnerId == _userId).ToArray(); var products = new List <ProductListItem>(); var runningTotal = 0m; foreach (InvoiceTransaction transaction in query) { var product = ctx.Products.FirstOrDefault(e => e.ProductId == transaction.ProductId); var newProduct = new ProductListItem { ProductId = product.ProductId, ProductName = product.ProductName, ProductPrice = product.ProductPrice, Quantity = product.Quantity, TotalPrice = product.TotalPrice }; products.Add(newProduct); runningTotal += product.TotalPrice; } return(new InvoiceDetail { InvoiceId = invoice.InvoiceId, BillAddress = invoice.BillAddress, BillName = invoice.BillName, CompanyName = invoice.CompanyName, CompanyAddress = invoice.CompanyAddress, CreatedUtc = invoice.CreatedUtc, ProductList = products, GrandTotal = runningTotal }); } }
async void GetHtmlAsync() { var url = TextBoxURL.Text; var httpclient = new HttpClient(); var html = await httpclient.GetStringAsync(url); var htmlDocument = new HtmlDocument(); htmlDocument.LoadHtml(html); var ProductsHtml = htmlDocument.DocumentNode.Descendants("ul") .Where(node => node.GetAttributeValue("id", "") .Equals("ListViewInner")).ToList(); var ProductListItems = ProductsHtml[0].Descendants("li") .Where(node => node.GetAttributeValue("id", "") .Contains("item")).ToList(); //Console.WriteLine(ProductListItems.Count()); //Console.WriteLine(); foreach (var ProductListItem in ProductListItems) { SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|Database2.mdf;Integrated Security=True"); SqlConnection conuser = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|Database2.mdf;Integrated Security=True"); con.Open(); conuser.Open(); SqlCommand cmd = new SqlCommand("insert into User_Data values(@Id,@Product_Name,@Cost,@Info,@Link)", con); SqlCommand cmduser = new SqlCommand("insert into Refer values (@EMAIL_ID,@Id)", con); cmd.Parameters.AddWithValue("@Id", ProductListItem.GetAttributeValue("listingid", ""));//ID cmduser.Parameters.AddWithValue("@EMAIL_ID", Session["User"]); cmduser.Parameters.AddWithValue("@Id", ProductListItem.GetAttributeValue("listingid", ""));//ID cmd.Parameters.AddWithValue("@Product_Name", ProductListItem.Descendants("h3") .Where(node => node.GetAttributeValue("class", "") .Equals("lvtitle")).FirstOrDefault().InnerText.Trim('\r', '\n', '\t'));//ProductName cmd.Parameters.AddWithValue("@Cost", ProductListItem.Descendants("li") .Where(node => node.GetAttributeValue("class", "") .Equals("lvprice prc")).FirstOrDefault().InnerText.Trim('\r', '\n', '\t'));//Price cmd.Parameters.AddWithValue("@Info", ProductListItem.Descendants("li") .Where(node => node.GetAttributeValue("class", "") .Equals("lvformat")).FirstOrDefault().InnerText.Trim('\r', '\n', '\t'));//ListingType cmd.Parameters.AddWithValue("@Link", ProductListItem.Descendants("a").FirstOrDefault().GetAttributeValue("href", ""));//URL cmd.ExecuteNonQuery(); cmduser.ExecuteNonQuery(); con.Close(); conuser.Close(); TextBoxURL.Text = ""; } }
public static ProductsList GetProductListFromOlx(ProductsList productsList, string str) { string url = ($"https://www.olx.pl/elektronika/komputery/katowice/q- {str} /?search%5Border%5D=filter_float_price%3Aasc&search%5Bdist%5D=5").Replace(" ", ""); string urlPage2 = ($"https://www.olx.pl/elektronika/komputery/katowice/q- {str} /?search%5Border%5D=filter_float_price%3Aasc&search%5Bdist%5D=5").Replace(" ", ""); List <string> urlList = new List <string>(); for (int i = 1; i < 30; i++) { urlPage2 = ($"https://www.olx.pl/elektronika/komputery/katowice/q- {str} /?search%5Border%5D=filter_float_price%3Aasc&search%5Bdist%5D=5&page = {i}").Replace(" ", ""); urlList.Add(urlPage2); } productsList = new ProductsList(); productsList.MyList = new List <Product>(); Parallel.ForEach(urlList, (urlAdress, state) => { var httpClient = new HttpClient(); var html = httpClient.GetStringAsync(urlAdress); var htmlDocument = new HtmlDocument(); htmlDocument.LoadHtml(html.Result); var ProductList = htmlDocument.DocumentNode.Descendants(0) .Where(n => n.HasClass("offer")).ToList(); var sb = new StringBuilder(); var test = htmlDocument.DocumentNode.Descendants("link") .Select(node => node.GetAttributeValue("href", "")) .FirstOrDefault(); if (!test.Contains("search")) { state.Break(); } foreach (var ProductListItem in ProductList) { string title; string price; string link; string image; try { title = ProductListItem.Descendants("a") .Where(node => node.GetAttributeValue("data-cy", "") .Equals("listing-ad-title")).FirstOrDefault() .InnerHtml.Trim('\r', '\t', '\n'); price = ProductListItem.Descendants("p") .Where(node => node.GetAttributeValue("class", "") .Equals("price")).FirstOrDefault() .InnerHtml.Trim('\r', '\t', '\n'); link = ProductListItem.Descendants("a") .Select(node => node.GetAttributeValue("href", "")) .FirstOrDefault().Trim(); image = ProductListItem.Descendants("img") .Select(node => node.GetAttributeValue("src", "")) .FirstOrDefault().Trim(); } catch (Exception) { continue; } var newProduct = new Product() { Title = title.ToString().Trim('\r', '\t', '\n').Replace("<strong>", "").Replace("</strong>", "").Replace(""", ""), Price = price.ToString().Trim('\r', '\t', '\n').Replace("<strong>", "").Replace("</strong>", ""), Link = link.ToString().Trim('\r', '\t', '\n'), Image = image.ToString().Trim('\r', '\t', '\n') }; try { if (productsList.MyList.Any(x => x.Title == newProduct.Title)) { continue; } } catch (Exception) { continue; } productsList.MyList.Add(newProduct); } }); //NON ASYNC //foreach (var urlAdress in urlList) //{ // var httpClient = new HttpClient(); // var html = await httpClient.GetStringAsync(urlAdress); // var htmlDocument = new HtmlDocument(); // htmlDocument.LoadHtml(html); // var ProductList = htmlDocument.DocumentNode.Descendants(0) // .Where(n => n.HasClass("offer")).ToList(); // var sb = new StringBuilder(); // var test = htmlDocument.DocumentNode.Descendants("link") // .Select(node => node.GetAttributeValue("href", "")) // .FirstOrDefault(); // if (!test.Contains("search")) // { // break; // } // foreach (var ProductListItem in ProductList) // { // string title; // string price; // string link; // string image; // try // { // title = ProductListItem.Descendants("a") // .Where(node => node.GetAttributeValue("data-cy", "") // .Equals("listing-ad-title")).FirstOrDefault() // .InnerHtml.Trim('\r', '\t', '\n'); // price = ProductListItem.Descendants("p") // .Where(node => node.GetAttributeValue("class", "") // .Equals("price")).FirstOrDefault() // .InnerHtml.Trim('\r', '\t', '\n'); // link = ProductListItem.Descendants("a") // .Select(node => node.GetAttributeValue("href", "")) // .FirstOrDefault().Trim(); // image = ProductListItem.Descendants("img") // .Select(node => node.GetAttributeValue("src", "")) // .FirstOrDefault().Trim(); // } // catch (Exception) // { // continue; // } // var newProduct = new Product() // { // Title = title.ToString().Trim('\r', '\t', '\n').Replace("<strong>", "").Replace("</strong>", "").Replace(""", ""), // Price = price.ToString().Trim('\r', '\t', '\n').Replace("<strong>", "").Replace("</strong>", ""), // Link = link.ToString().Trim('\r', '\t', '\n'), // Image = image.ToString().Trim('\r', '\t', '\n') // }; // if (result.MyList.Any(x => x.Title == newProduct.Title)) // continue; // result.MyList.Add(newProduct); // } //} //TODO: Order by price or search engine productsList.MyList = productsList.MyList.OrderBy(p => p.Price).ToList(); return(productsList); }
public void UpdateProductCatalogItem(int item, ProductListItem productListItem) { var adapter = recycler.GetAdapter() as ProductCatalogAdapter; adapter.NotifyItemChanged(item); }
static async void GetHtmlAsync() { var url = "https://www.otodom.pl/sprzedaz/mieszkanie/warszawa/?search%5Bregion_id%5D=7&search%5Bsubregion_id%5D=197&search%5Bcity_id%5D=26&nrAdsPerPage=72"; var httpclient = new HttpClient(); var html = await httpclient.GetStringAsync(url); var htmlDocument = new HtmlDocument(); htmlDocument.LoadHtml(html); var ProductsHtml = htmlDocument.DocumentNode.Descendants("div"). Where(node => node.GetAttributeValue("class", "").Equals("listing")).ToList(); var ProductListItems = new List <HtmlNode>(); try { ProductListItems = ProductsHtml[0].Descendants("article") .Where(node => node.GetAttributeValue("data-item-id", "") != null).ToList(); } catch (Exception e) { Console.WriteLine("No ni działa"); } Console.WriteLine(); Console.WriteLine("Liczba ofert: " + ProductListItems.Count()); Console.WriteLine("Wyniki:"); Console.WriteLine(); foreach (var ProductListItem in ProductListItems) { Console.WriteLine(); //ID Console.WriteLine("ID: " + ProductListItem.GetAttributeValue("data-item-id", "")); //Nazwa Console.WriteLine(ProductListItem.Descendants("span") .Where(node => node.GetAttributeValue("class", "") .Equals("offer-item-title")).FirstOrDefault().InnerText.Trim('\r', '\n', '\t')); //Mieszkanie/Dom + Kupno/Sprzedaż + Dzielnica Console.WriteLine(ProductListItem.Descendants("p") .Where(node => node.GetAttributeValue("class", "") .Equals("text-nowrap")).FirstOrDefault().InnerText.Trim('\r', '\n', '\t') ); // Metraż Console.WriteLine(ProductListItem.Descendants("li") .Where(node => node.GetAttributeValue("class", "") .Equals("hidden-xs offer-item-area")).FirstOrDefault().InnerText.Trim('\r', '\n', '\t')); //Koszt Console.WriteLine(ProductListItem.Descendants("li") .Where(node => node.GetAttributeValue("class", "") .Equals("hidden-xs offer-item-price-per-m")).FirstOrDefault().InnerText.Trim('\r', '\n', '\t') ); Console.WriteLine(ProductListItem.Descendants("li") .Where(node => node.GetAttributeValue("class", "") .Equals("offer-item-price")).FirstOrDefault().InnerText.Trim(' ', '\r', '\n', '\t') ); //URL Console.WriteLine("URL OFERTY: " + ProductListItem.Descendants("a").FirstOrDefault().GetAttributeValue("href", "") ); //URL zdjęcia Console.WriteLine("URL zdjęcia: " + ProductListItem.Descendants("span") .Where(node => node.GetAttributeValue("class", "") .Equals("img-cover lazy")).FirstOrDefault().GetAttributeValue("data-src", "") ); Console.WriteLine(); } }
static async void GetHtmlAsync() { var url = "https://www.ebay.ca/sch/i.html?_odkw=xbox+one&_osacat=0&_from=R40&_trksid=p2045573.m570.l1313.TR12.TRC2.A0.H0.Xlaptop.TRS0&_nkw=laptop&_sacat=200"; var httpclient = new HttpClient(); var html = await httpclient.GetStringAsync(url); //parse html doc var htmlDocument = new HtmlDocument(); htmlDocument.LoadHtml(html); //load doc for parsing var ProductsHtml = htmlDocument.DocumentNode.Descendants("ul") .Where(node => node.GetAttributeValue("id", "") .Equals("ListViewInner")).ToList(); var ProductListItems = ProductsHtml[0].Descendants("li") .Where(node => node.GetAttributeValue("id", "") .Contains("item")).ToList(); Console.WriteLine(ProductListItems.Count()); Console.WriteLine(); foreach (var ProductListItem in ProductListItems) { //ID string pid = (ProductListItem.GetAttributeValue("listingid", "")); Console.WriteLine(pid); //ProductName string ProductName = ProductListItem.Descendants("h3") .Where(node => node.GetAttributeValue("class", "") .Equals("lvtitle")).FirstOrDefault().InnerText.Trim('\r', '\n', '\t'); Console.WriteLine(ProductName); //Price string price = ProductListItem.Descendants("li") .Where(node => node.GetAttributeValue("class", "") .Equals("lvprice prc")).FirstOrDefault().InnerText.Trim('\r', '\n', '\t'); Console.WriteLine(price); //ID Console.WriteLine(ProductListItem.GetAttributeValue("listingid", "")); //ProductName Console.WriteLine(ProductListItem.Descendants("h3") .Where(node => node.GetAttributeValue("class", "") .Equals("lvtitle")).FirstOrDefault().InnerText.Trim('\r', '\n', '\t')); //Price Console.WriteLine(ProductListItem.Descendants("li").Where(node => node.GetAttributeValue("class", "").Equals("lvprice prc")).FirstOrDefault().InnerText.Trim('\r', '\n', '\t')); //ListingType string ListingType = ProductListItem.Descendants("li") .Where(node => node.GetAttributeValue("class", "") .Equals("lvformat")).FirstOrDefault().InnerText.Trim('\r', '\n', '\t'); // Console.WriteLine(ListingType); //URL string purl = ProductListItem.Descendants("a").FirstOrDefault().GetAttributeValue("href", ""); Console.WriteLine(purl); string csvRow = string.Format("{0},{1},{2}", pid, ProductName, price); // string path = @"D:\Nital\Summer 2020\BDAT 1007 - Social Data Mining\S20Practical\WebScraping_Ebay\data.txt"; //File.AppendAllText(path, (csvRow)); Console.WriteLine(); } }
private ListResult <ProductListItem> GetSuggestProducts(int siteId, string userId, string appId, int count) { //猜你喜欢没有实现,准确的应该按客户的浏览历史来 int intUserId = 0; string username = ""; Member member = GetMember(userId.ToSeesionId()); if (member != null) { intUserId = member.UserId; username = member.Username; } DataTable dt = ProductBrowser.GetSuggestProducts(intUserId, username, count); //TODO List <ProductListItem> products = new List <ProductListItem>(); if (dt != null) { ProductListItem item = null; foreach (DataRow row in dt.Rows) { item = new ProductListItem(); item.ProductId = 0; if (row["ProductId"] != DBNull.Value) { item.ProductId = (int)row["ProductId"]; } item.CategoryId = 0; if (row["CategoryId"] != DBNull.Value) { item.CategoryId = (int)row["CategoryId"]; } item.Title = ""; if (row["ProductName"] != DBNull.Value) { item.Title = (string)row["ProductName"]; } item.ImageUrl = ""; if (row["ThumbnailUrl220"] != DBNull.Value) { item.ImageUrl = Util.AppendImageHost((string)row["ThumbnailUrl220"]); } item.SalePrice = 0; if (row["SalePrice"] != DBNull.Value) { item.SalePrice = (decimal)row["SalePrice"]; } item.MarketPrice = 0; if (row["MarketPrice"] != DBNull.Value) { item.MarketPrice = (decimal)row["MarketPrice"]; } item.Quantity = 0; if (row["Stock"] != DBNull.Value) { item.Quantity = (int)row["Stock"]; } item.HasSku = false; if (row["fastbuy_skuid"] != DBNull.Value) { item.SkuId = (string)row["fastbuy_skuid"]; item.HasSku = item.SkuId.Equals(""); } if (item.HasSku) { item.SkuItems = this.GetSkuItems(item.ProductId); item.Skus = this.GetSkus(ProductBrowser.GetProductSkus(item.ProductId)); } item.ShortDescription = ""; if (row["ShortDescription"] != DBNull.Value) { item.ShortDescription = (string)row["ShortDescription"]; } if (row["IsCollect"] != DBNull.Value) { item.IsCollect = (int)row["IsCollect"]; } item.ShortDescription = ""; if (row["ShortDescription"] != DBNull.Value) { item.ShortDescription = (string)row["ShortDescription"]; } item.IsCustomsClearance = false; if (row["IsCustomsClearance"] != DBNull.Value) { item.IsCustomsClearance = (bool)row["IsCustomsClearance"]; } item.IsFreeShipping = false; if (row["IsfreeShipping"] != DBNull.Value) { item.IsFreeShipping = (bool)row["IsfreeShipping"]; } item.ShippingMode = ""; if (row["ShippingMode"] != DBNull.Value) { item.ShippingMode = (string)row["ShippingMode"]; } item.SaleCounts = 0; if (row["SaleCounts"] != DBNull.Value) { item.SaleCounts = (int)row["SaleCounts"]; } item.VistiCounts = 0; if (row["VistiCounts"] != DBNull.Value) { item.VistiCounts = (int)row["VistiCounts"]; } item.BuyCardinality = 1; if (row["BuyCardinality"] != DBNull.Value) { item.BuyCardinality = (int)row["BuyCardinality"]; } item.Icon = ""; if (row["Icon"] != DBNull.Value) { item.Icon = Util.AppendImageHost((string)row["Icon"]); } item.ShopName = ""; if (row["ShopName"] != DBNull.Value) { item.ShopName = (string)row["ShopName"]; } bool IsDisplayDiscount = false; if (row["IsDisplayDiscount"] != DBNull.Value) { IsDisplayDiscount = (bool)row["IsDisplayDiscount"]; } item.Discount = ""; if (IsDisplayDiscount && item.MarketPrice > 0) { item.Discount = (item.SalePrice * 10 / item.MarketPrice).ToString("0.00") + "折"; } decimal mintaxrate = 0M; if (row["MinTaxRate"] != System.DBNull.Value) { mintaxrate = (decimal)row["MinTaxRate"]; } decimal maxtaxrate = 0M; if (row["MaxTaxRate"] != System.DBNull.Value) { maxtaxrate = (decimal)row["MaxTaxRate"]; } item.TaxRate = 0; if (row["TaxRate"] != DBNull.Value) { item.TaxRate = (decimal)row["TaxRate"]; } item.ExtendTaxRate = item.GetExtendTaxRate(item.TaxRate, mintaxrate, maxtaxrate); products.Add(item); } } ListResult <ProductListItem> data = new ListResult <ProductListItem>(); data.TotalNumOfRecords = products.Count; data.Results = products; return(data); }
public ActionResult <IEnumerable <ProductListItem> > Search(string ProductCodes, string Description, Families?Family, string Style, int?Level, string SupplierCode, string ClassCode, bool?IsActive = true) { if (string.IsNullOrWhiteSpace(ProductCodes) && string.IsNullOrWhiteSpace(Description) && !Family.HasValue && string.IsNullOrWhiteSpace(Style) && string.IsNullOrWhiteSpace(SupplierCode) && string.IsNullOrWhiteSpace(ClassCode)) { throw new Exception("At least one parameter is needed to call this api"); } var qryProducts = from P in DBContext.PD_S_PRODUCT /* * join PE in DBContext.PD_S_PRODUCT_EXT_AUS on P.PRODUCT_CODE equals PE.PRODUCT_CODE into Ext * join PC in DBContext.PD_S_CLASS on P.CLASS_CODE equals PC.CLASS_CODE into Class * join PSC in DBContext.PD_S_SUBCLASS on new { P.COMPANY_CODE, P.DIVISION_CODE, P.CLASS_CODE, P.SUBCLASS_CODE } equals new { PSC.COMPANY_CODE, PSC.DIVISION_CODE, PSC.CLASS_CODE, PSC.SUBCLASS_CODE } into SubClass * join PG in DBContext.PD_S_GROUP on P.GROUP_CODE equals PG.GROUP_CODE into Group * join PW in DBContext.PD_S_PRODUCT_WARRANTIES_EXT_AUS on P.PRODUCT_CODE equals PW.PRODUCT_CODE into Warranty * join PL in DBContext.PD_S_PRODUCT_PRICELIST on P.PRODUCT_CODE equals PL.PRODUCT_CODE into PriceList * join PB in DBContext.PD_S_BAND on P.BAND_CODE equals PB.BAND_CODE into Band * join PS in DBContext.PD_S_SUPPLIER on P.SUPPLIER_CODE equals PS.SUPPLIER_CODE into Supplier */ join PE in DBContext.PD_S_PRODUCT_EXT_AUS on new { P.COMPANY_CODE, P.DIVISION_CODE, P.PRODUCT_CODE } equals new { PE.COMPANY_CODE, PE.DIVISION_CODE, PE.PRODUCT_CODE } into Ext join PC in DBContext.PD_S_CLASS on new { P.COMPANY_CODE, P.DIVISION_CODE, P.CLASS_CODE } equals new { PC.COMPANY_CODE, PC.DIVISION_CODE, PC.CLASS_CODE } into Class join PSC in DBContext.PD_S_SUBCLASS on new { P.COMPANY_CODE, P.DIVISION_CODE, P.CLASS_CODE, P.SUBCLASS_CODE } equals new { PSC.COMPANY_CODE, PSC.DIVISION_CODE, PSC.CLASS_CODE, PSC.SUBCLASS_CODE } into SubClass join PG in DBContext.PD_S_GROUP on new { P.COMPANY_CODE, P.DIVISION_CODE, P.GROUP_CODE } equals new { PG.COMPANY_CODE, PG.DIVISION_CODE, PG.GROUP_CODE } into Group join PW in DBContext.PD_S_PRODUCT_WARRANTIES_EXT_AUS on new { P.COMPANY_CODE, P.DIVISION_CODE, P.PRODUCT_CODE } equals new { PW.COMPANY_CODE, PW.DIVISION_CODE, PW.PRODUCT_CODE } into Warranty join PL in DBContext.PD_S_PRODUCT_PRICELIST on new { P.COMPANY_CODE, P.DIVISION_CODE, P.PRODUCT_CODE } equals new { PL.COMPANY_CODE, PL.DIVISION_CODE, PL.PRODUCT_CODE } into PriceList join PB in DBContext.PD_S_BAND on new { P.COMPANY_CODE, P.DIVISION_CODE, P.BAND_CODE } equals new { PB.COMPANY_CODE, PB.DIVISION_CODE, PB.BAND_CODE } into Band join PS in DBContext.PD_S_SUPPLIER on new { P.COMPANY_CODE, P.DIVISION_CODE, P.SUPPLIER_CODE } equals new { PS.COMPANY_CODE, PS.DIVISION_CODE, PS.SUPPLIER_CODE } into Supplier select new ProductDBInfo { Product = P, ProductExt = Ext.SingleOrDefault(), ProductClass = Class.Where(E => E.DT_START.GetValueOrDefault(DateTime.MinValue) <= DateTime.Today && E.DT_END.GetValueOrDefault(DateTime.MaxValue) <= DateTime.Today).FirstOrDefault(), ProductSubClass = SubClass.Where(E => E.DT_START.GetValueOrDefault(DateTime.MinValue) <= DateTime.Today && E.DT_END.GetValueOrDefault(DateTime.MaxValue) <= DateTime.Today).FirstOrDefault(), ProductGroup = Group.Where(E => E.DT_START.GetValueOrDefault(DateTime.MinValue) <= DateTime.Today && E.DT_END.GetValueOrDefault(DateTime.MaxValue) <= DateTime.Today).FirstOrDefault(), ProductBand = Band.Where(E => E.DT_START.GetValueOrDefault(DateTime.MinValue) <= DateTime.Today && E.DT_END.GetValueOrDefault(DateTime.MaxValue) <= DateTime.Today).FirstOrDefault(), ProductWarranty = Warranty.OrderByDescending(E => E.DT_EFFECTIVE_FROM).FirstOrDefault(E => E.DT_EFFECTIVE_FROM <= DateTime.Today), ProductSupplier = Supplier.Where(E => E.DT_START.GetValueOrDefault(DateTime.MinValue) <= DateTime.Today && E.DT_END.GetValueOrDefault(DateTime.MaxValue) <= DateTime.Today).FirstOrDefault(), ProductPriceList = PriceList.Where(E => E.DT_VALID <= DateTime.Today).OrderByDescending(E => E.DT_VALID) }; var predicate = PredicateBuilder.New <ProductDBInfo>(true); if (!string.IsNullOrWhiteSpace(ProductCodes)) { string[] ProductList = ProductCodes.Split("|", StringSplitOptions.RemoveEmptyEntries); if (ProductList.Length > 0) { predicate = predicate.And(E => ProductList.Contains(E.Product.PRODUCT_CODE)); } } if (!string.IsNullOrWhiteSpace(Description)) { predicate = predicate.And(E => E.Product.PRODUCT_DESCR.Contains(Description)); } if (Level.HasValue) { predicate = predicate.And(E => E.Product.BAND_CODE == Level.Value.ToString()); } if (!string.IsNullOrWhiteSpace(Style)) { predicate = predicate.And(E => E.Product.SUBCLASS_CODE == Style); } if (Family.HasValue) { string PEDescription = Family.Value.GetDescription(); predicate = predicate.And(E => E.ProductExt != null && E.ProductExt.PRODUCT_COMMER != null && E.ProductExt.PRODUCT_COMMER.StartsWith(PEDescription)); } if (!string.IsNullOrWhiteSpace(SupplierCode)) { string[] SupplierList = SupplierCode.Split("|", StringSplitOptions.RemoveEmptyEntries); if (SupplierList.Length > 0) { predicate = predicate.And(E => SupplierList.Contains(E.Product.SUPPLIER_CODE)); } } if (!string.IsNullOrWhiteSpace(ClassCode)) { predicate = predicate.And(E => E.Product.CLASS_CODE == ClassCode); } List <ProductListItem> Result = new List <ProductListItem>(); foreach (ProductDBInfo Item in qryProducts.Where(predicate).Take(Settings.Value.MaxQueryResult)) { ProductListItem ResultItem = new ProductListItem(Item); Result.Add(ResultItem); } return(Result); }
dynamic MapProduct(ProductListItem p) { return new { id = p.ProductId, partId = p.Product.PartId, dispPartId = p.Product.DisplayPartId, name = p.Product.DisplayName, desc = p.Product.Description, shade = p.Product.ShadeName, price = p.Product.ListPrice, cdsFree = p.Product.CDSFree, isGift = p.Product.IsGift, isSample = p.Product.IsSample, isLimited = p.Product.IsLimitedEdition, useupRate = 0, // p.UseUpRateInDays, // TODO: add useupRate when supported from endeca listImage = MapImageUrl(p.Product.HeroListImagePath) }; }
private static async void GetHtmlAsync() { var url = "https://www.amazon.com/s?k=doom+patrol+omnibus&crid=2HBTXIE5Z803G&sprefix=Doom+pat%2Caps%2C176&ref=nb_sb_ss_i_4_8"; var httpClient = new HttpClient(); var html = await httpClient.GetStringAsync(url); var htmlDocument = new HtmlDocument(); htmlDocument.LoadHtml(html); // Gets List var ProductsHtml = htmlDocument.DocumentNode.Descendants("div") .Where(node => node.GetAttributeValue("class", "") .Equals("s-main-slot s-result-list s-search-results sg-row")).ToList(); var ProductListItems = ProductsHtml[0].Descendants("div") .Where(node => node.GetAttributeValue("data-asin", "") //data-asin .Contains("1")).ToList(); //1 //Console.WriteLine(ProductListItems.Count()); //Console.WriteLine(); foreach (var ProductListItem in ProductListItems) { // id Console.WriteLine(ProductListItem.GetAttributeValue("data-index", "")); // ProductName Console.WriteLine(ProductListItem.Descendants("a") .Where(node => node.GetAttributeValue("class", "") .Equals("a-link-normal a-text-normal")).FirstOrDefault().InnerText.Trim('\r', '\n', '\t') ); //// Subtitle Console.WriteLine(ProductListItem.Descendants("span") .Where(node => node.GetAttributeValue("class", "") .Contains("a-")).FirstOrDefault().InnerText.Trim('\r', '\n', '\t') ); // Price Console.WriteLine( Regex.Match( ProductListItem.Descendants("a") .Where(node => node.GetAttributeValue("class", "") .Equals("a-size-base a-link-normal a-text-normal")).FirstOrDefault().InnerText , @"\$\d+.\d+") ); // Book Type Console.WriteLine( ProductListItem.Descendants("a") .Where(node => node.GetAttributeValue("class", "") .Equals("a-size-base a-link-normal a-text-bold")).FirstOrDefault().InnerText.Trim('\r', '\n', '\t') ); //// Url //Console.WriteLine( // ProductListItem.Descendants("a").FirstOrDefault().GetAttributeValue("href", "").Trim('\r', '\n', '\t') // ); //Console.WriteLine(); } }