Quantcast
Channel: htmlagilitypack Forum Rss Feed
Viewing all articles
Browse latest Browse all 450

New Post: why doesn't work my code on windows 8 app ?

$
0
0
private void button1_Click(object sender, EventArgs e)
        {
            Uri url = new Uri("http://www.dr.com.tr/Catalog/Categories/FilterProducts/?Id=4645&type=12");
            WebClient client = new WebClient();
            string html = client.DownloadString(url);
            HtmlAgilityPack.HtmlDocument dokuman = new HtmlAgilityPack.HtmlDocument();
      
            dokuman.LoadHtml(html);
   
            HtmlNodeCollection basliklar = dokuman.DocumentNode.SelectNodes("//h2[@class='product_name']");

           
           
            foreach (var baslik in basliklar)
            {
                listBox1.Items.Add(baslik.InnerText);
 
            }
            basliklar = dokuman.DocumentNode.SelectNodes("//span[@class='sale-price']");
            foreach (var baslik in basliklar)
            {
                listBox2.Items.Add(baslik.InnerText);
        
            }
            basliklar = dokuman.DocumentNode.SelectNodes("//h3");
            foreach (var baslik in basliklar)
            {
                listBox3.Items.Add(baslik.InnerText);
    
              
            }

            string regex = @"src=[\'" + "\"" + @"]?([^\'" + "\"]+.jpg)";
            System.Text.RegularExpressions.Regex Reg = new System.Text.RegularExpressions.Regex(regex);
            System.Text.RegularExpressions.MatchCollection yakala = Reg.Matches(html);
            foreach (System.Text.RegularExpressions.Match link in yakala)
            {
               listBox4.Items.Add( link.ToString().Substring(5,link.Length-5) + "\r\n");

            }

            pictureBox1.ImageLocation = listBox4.Items[0].ToString();
            label1.Text = listBox1.Items[0].ToString();
            label2.Text = listBox2.Items[0].ToString();
            label3.Text = listBox3.Items[0].ToString();
        }
Firstly I wrote form application and this code worked. And then I use this codes my windows store app project but code doesn't work.
first error here ; string html = client.DownloadString(url);

second error : HtmlNodeCollection basliklar = dokuman.DocumentNode.SelectNodes("//h2[@class='product_name']"); 'HtmlAgilityPack.HtmlNode' does not contain a definition for 'SelectNodes' and no extension method 'SelectNodes' accepting a first argument of type 'HtmlAgilityPack.HtmlNode' could be found (are you missing a using directive or an assembly reference?)

Viewing all articles
Browse latest Browse all 450

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>