Click here to Skip to main content
15,890,440 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Actually i want to make a application that can search documents only from web.

What I have tried:

private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                String url = textBox1.Text;
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                StreamReader sr = new StreamReader(response.GetResponseStream());
                HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
                doc.Load(sr);
                var aTags = doc.DocumentNode.SelectNodes("//a");
                int counter = 1;
                if (aTags != null)
                {
                    foreach (var aTag in aTags)
                    {
                        richTextBox1.Text += aTag.InnerHtml + "\n";
                        counter++;
                    }
                }
                sr.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to retrieve related keywords." + ex);
            }
Posted
Comments
Member 12982873 16-May-18 16:12pm    
it search only text html type file not documents
Member 12982873 16-May-18 16:24pm    
Any body help ?
j snooze 16-May-18 17:17pm    
What documents are you talking about? If you think you're going to write c# code to access every web server out there to search through the documents contained on that server then you would be a hacker and that website would have a major security hole.
I don't know what else you would be asking if you aren't talking about the html of a page.
Member 12982873 17-May-18 0:38am    
just specific site. i will type url in text box and result will be there for document search from given url
Member 12982873 17-May-18 0:40am    
any document doc files from given url

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