- 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("forgetcode.com.*%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;
- }
- }
- }