Results 1 to 3 of 3

Thread: [RESOLVED] Google search query (working with url encoding)

  1. #1

    Thread Starter
    Frenzied Member stateofidleness's Avatar
    Join Date
    Jan 2009
    Posts
    1,780

    Resolved [RESOLVED] Google search query (working with url encoding)

    Gents,
    I'm trying to take a google url query, parse out the actual query:

    Example:
    this+is+my+(%22test%22+OR+%22query%22)

    I'd like to be able to convert the "+" to a space, and the "%22" to quotes, for displaying to the user. They'll be able to type a new query (free form) and I'll have to convert it back to the format above with the "+" and "%22" if necessary.

    I've worked with .IndexOf a bit, but not sure how to replace the characters and such to convert it back and forth.

    is that considered "url encoded"? is there a method that will take a string and ouput it in the above format for me?

    thanks!

  2. #2
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: Google search query (working with url encoding)

    I believe there is a UrlEncode method in a class called HttpUtility..if my memory serves me right. Hopefully theres is a corresponding "UrlDecode" method for what you need.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  3. #3

    Thread Starter
    Frenzied Member stateofidleness's Avatar
    Join Date
    Jan 2009
    Posts
    1,780

    Re: Google search query (working with url encoding)

    That's just what I needed! Works beautifully!

    For others that may come along and read this:
    First, ADD THE REFERENCE to System.Web (Project > Add Reference > System.Web)
    Second, Import System.Web
    To encode/decode: HttpUtility.Encode("String to encode") or HttpUtility.Decode("String to decode")

    Thanks again!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width