Results 1 to 3 of 3

Thread: [2.0] Searching through text

  1. #1

    Thread Starter
    Hyperactive Member francisstokes's Avatar
    Join Date
    May 2005
    Location
    Kent, England
    Posts
    272

    [2.0] Searching through text

    It's been a while since i've done any coding at all, but i'm about to make a little app that downloads a html file and searches through it for a specific line.
    How would i search the file and find the line?
    Thanks

  2. #2

    Thread Starter
    Hyperactive Member francisstokes's Avatar
    Join Date
    May 2005
    Location
    Kent, England
    Posts
    272

    Re: [2.0] Searching through text

    Argh. Doesn't matter now, it turns out the request has to be made from a real browser

  3. #3
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704

    Re: [2.0] Searching through text

    Code:
    using System;
    using System.IO;
    using System.Net;
    using System.Text.RegularExpressions;
    
    string htmlData;
    Uri requestUri = new Uri("http://www.google.com");
    HttpWebRequest request = WebRequest.Create(requestUri) As HttpWebRequest;
    HttpWebResponse response;
    response = request.GetResponse() as HttpWebResponse;
    using (StreamReader reader = new StreamReader(response.GetResponseStream())
    {
     htmlData = reader.ReadToEnd();
    }
    
    response.Close();
    
    //search the string
    Regex regex = new Regex(searchPattern);
    Match match = regex.Match();
    if (match.Success)
    {
      Console.WriteLine("found");
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width