Forget Code launches a powerful code generator for building API's

Extract Search Keyword from Google, Yahoo and other search URL in C#

Every web site has major percentage of referral traffic from Google, so it is necessary to understand what keyword do users search and reach the website.
The following code extracts the search keyword from Google, Yahoo, etc

using System;
using System.Collections.Generic;
using System.Net;
using System.Text;
using System.Web;
using System.Text.RegularExpressions;
namespace forgetcode
    class Program
         static void Main(string[] args)
             Uri referrer = HttpContext.Current.Request.UrlReferrer;
            if (referrer != null)
                string original = referrer.OriginalString.ToLower();
                string keyword = GetKeyword(original);
                Console.WriteLine("Visitor Searched For "+keyword);
        private static string GetKeyword(string strU)
            Regex regKeyword = new Regex("(p|q)=(?<keyword>.*?)&", RegexOptions.IgnoreCase | RegexOptions.Multiline);
            Regex regSnippet = new Regex("*%2F(?<id>\\d+)%2F", RegexOptions.IgnoreCase | RegexOptions.Multiline);
            Match match = regKeyword.Match(strU);
            string keyword = match.Groups["keyword"].ToString();
            // Get the decoded URL
            string result = HttpUtility.UrlDecode(keyword);
            // Get the HTML representation
            result = HttpUtility.HtmlEncode(result);
            return result;

Note : This code / any code will not work if the user is logged in, Google encrypts search URL when the user is logged in.