Extract Email addresses from given web url
In this Beginners article we will see how simple it is to extract an email addresses from web page.
for demo purpose We will extract all emails from
URL:// http://eggheadcafe.com/aboutus.aspx
Here we will use Email validation regular expression.
You can develop your own regular field validation expressions using Free Expresso tool
Link to download expresso tool for to Learn regualr field expressions in 60min.
http://www.ultrapico.com/Expresso.htm
Here is this line of code
protected
void Button1_Click(object sender, EventArgs e)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://www.nullskull.com/aboutus.aspx"); // Create WebRequest
HttpWebResponse response = (HttpWebResponse)request.GetResponse(); // Initialise the connection
StreamReader reader = new StreamReader(response.GetResponseStream()); // Start receving the Response and store it in to Stream and pass it to Stream reader
string responseText = reader.ReadToEnd();
// Here we will apply regualr expression to responseText
Regex re = new Regex(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"); //string pattern is Email validation Expressioin
MatchCollection me = re.Matches(responseText);
String str = string.Empty;
foreach(Match m in me)
{
str += m.Value +
" , " ;
}
Response.Write(str);
}
By Sat Sat Popularity (2173 Views)