Click here to Skip to main content
15,891,372 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to pull data from web pages. I pulled data web page's firt page but I don't pull datas second page. I must pull second page's datas. Can you help me. Fisrt page code:

C#
static void Main(string[] args)
        {
            WebRequest wRequest = WebRequest.Create("http://www.posta.com.tr/");
            WebResponse GelenCevap = wRequest.GetResponse();

            string kaynak;
            StreamReader reader = new StreamReader(GelenCevap.GetResponseStream(), Encoding.UTF8);
            kaynak = reader.ReadToEnd();

            HtmlDocument dokuman = new HtmlDocument();
            dokuman.LoadHtml(kaynak);

            HtmlNode nesne = dokuman.DocumentNode;

            var baslikListesi = nesne.Descendants("div").Where(a => a.GetAttributeValue("class", "") == "list4").ToList();
            
            HtmlNodeCollection icerikler = dokuman.DocumentNode.SelectNodes("//div[@class=\"detailSpot\"]"); 
           
               
            List<string> liste=new List<string>();
            foreach (var baslik in baslikListesi)
            {
                liste.Add(baslik.InnerText);
            }
            for (int i = 0; i < liste.Count; i++)
            {
                Console.WriteLine(liste[i]);
               
            }
            Console.WriteLine(icerikler);
            Console.ReadLine(); 
        }
Posted
Updated 28-Apr-14 15:21pm
v2
Comments
ZurdoDev 28-Apr-14 14:15pm    
Why can't you pull the second page?
DamithSL 28-Apr-14 22:43pm    
unclear, what you mean by second page? is it another page of http://www.posta.com.tr/ site or different site?
allein@esra 29-Apr-14 7:46am    
with this code, I can pull the title of the topical news on this site (www.posta.com.tr) but I dont pull this title' content. I trying this code;

HtmlNodeCollection icerikler = dokuman.DocumentNode.SelectNodes("//div[@class=\"detailSpot\"]");

but this code doesnt work
do I write wrong or incomplete?

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900