Monday, March 12, 2012

get the search term from a URL

Hi guys,

I have a field called URL in my table. I want to get the SEARCH TERM from a given URL. I'm getting difficulties, because the URL have different format depending up on the search engine
that the users use to browse. Some of the search engines are "google",".excite.com", "search.msn.","search.netscape", "search.lycos", "altavista", "search.yahoo" and many more.

Examples of the URLs from google :

http://www.google.com/search?q=S26+Collet+Chuck&hl=en&client=firefox-a&rls=org.mozilla:en-USSurprisefficial&start=30&sa=N -- The search term is S26 Collet Chuck
http://www.google.com/search?sourceid=navclient&ie=UTF-8&rls=GGLG,GGLG:2006-02,GGLG:en&q=kt21+kia -- The search term is kt21 kia
http://www.google.com/search?hl=en&q=Slagger+burning+Tables -- The search term is Slagger burning Tables


Does anybody have a sql query to get the SEARCH TERM from different search engine (URL).

Thanks in advance.

Sounds like a fairly tricky piece of work that.

All i can really add is that as it's essentially string parsing, you'd be best doing this outside of T-SQL either in your app code or in a CLR function.

|||

RegX (Regular Expressions) is your FRIEND in situations like this.

You really, really want to do this in application code using RegX. It is so much more efficient!!!

If absolutely necessary, you could create a CLR function (in VB or C#), using RegX, and add that CLR function to your server. You could then call it from SQL code.

No comments:

Post a Comment