|
-
Aug 30th, 2007, 07:27 AM
#1
Thread Starter
Hyperactive Member
[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
-
Aug 30th, 2007, 08:21 AM
#2
Thread Starter
Hyperactive Member
Re: [2.0] Searching through text
Argh. Doesn't matter now, it turns out the request has to be made from a real browser
-
Aug 31st, 2007, 07:40 AM
#3
I wonder how many charact
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|