SCalkins Posted March 18, 2014 Posted March 18, 2014 I'm trying to setup an alfred workflow to open a URL with a search query. Example: 1) I want to search for someone named 'John Doe' with the following domain: http://www.whitepages.com/name/John-Doe How do I Encode Spaces as '-' Dashes? 2) Same Scenario, but encode spaces as '/' OR '%2F' http://radaris.com/p/John%2FDoe/ http://radaris.com/p/John/Doe/
deanishe Posted March 19, 2014 Posted March 19, 2014 That depends on which programming language you're using. In Python, it'd be one of: query = query.replace(' ', '-') query = query.replace(' ', '/') query = query.replace(' ', '%2F')
jdfwarrior Posted March 19, 2014 Posted March 19, 2014 I'm trying to setup an alfred workflow to open a URL with a search query. Example: 1) I want to search for someone named 'John Doe' with the following domain: http://www.whitepages.com/name/John-Doe How do I Encode Spaces as '-' Dashes? 2) Same Scenario, but encode spaces as '/' OR '%2F' http://radaris.com/p/John%2FDoe/ http://radaris.com/p/John/Doe/ As deanishe said, it all depends on the language that you are using. Some languages you would have to set up a manual list of character replacements. PHP has a urlencode() function that will handle a lot of the encoding for you.
deanishe Posted March 19, 2014 Posted March 19, 2014 Many languages have a urlencode() function, but that will only get you the / -> %2F in your examples. Spaces will either be encoded to %20 or +, depending on options.
SCalkins Posted March 20, 2014 Author Posted March 20, 2014 That depends on which programming language you're using. In Python, it'd be one of: query = query.replace(' ', '-') query = query.replace(' ', '/') query = query.replace(' ', '%2F') I'm not using any language at the moment, I have yet to develop any workflow. I was attempting to do it with the custom web search. As far as developing a workflow is there any sample/example workflows that I can look at that might be similar to what I'm trying to accomplish?
deanishe Posted March 20, 2014 Posted March 20, 2014 If you want to do it with a custom web search, you should include site:whitepages.com in the query part of the URL (for Google). Or inurl:whitepages.com/name/.For example, your custom search URL for whitepages.com might be: https://www.google.com/search?q=site:whitepages.com+{query}
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now