Generic search syntax

i want to ask websites via applescript for their particular search syntax. Is this possible?

Hi Joy,

I don’t have an answer to your question, but do all sites have search syntax, whatever that is?


I’m not sure what you mean. Google for instance uses the meta tag ‘description’ (read: google’s SEO). There are a few keywords, but are low priority. Then there is the use of headings in the site and paragraph tags that should be used properly. So there is not an syntax for an site but ranking depends how well your site is built and if it contains good information. It’s the formula of google’s success otherwise altavista would still be #1.

But if you want to read meta tags, that would be possible.

I have a “one size fits all” solution to this, I search by google, and use the site parameter, then anymore parameters, link inlink and what not.

I think every search engine have slightly varied syntax, but they are still better at generalizing it, then going to different sites, as there aren’t any standard per se. But a site with tailor-sewn search enging, is of course to prefer if you have to perform complex searches.

Hi guys,
sorry, my question was too generic.
What i want to archive is to add the right search tags at the end of the hypertext transfer protocol address. This, because i want to accelerate my researches on reference material i need for my professional education and work.
For some time now, i used to add text blocks at the end of addresses. Some question tags are rather long, and need some parsing, before they’re usable as search-tags.

set kyw to "tolstoy"
set gbooks to ""
set ask_search_tags to my get_tags(kyw)
open location (gbooks&ask_search_tags as text)


You’ll find everything you need here with regards to encoding, but here it is.

Say you have searched a site, that sends the url in the open (http GET). When you send the search, it will be encoded so that the searchstring is valid, and won’t be interpreted errantly.

So you’ll first need to decode the url, then you’ll need to get the site away with text item delimiters, then your searchword, and then you are left with several text items, which you can reconstruct into a searchstring, by using your search word or phrase as a delimiter. This string you’ll have to encode again, before feeding it to you browser.
(After having reassembled it with the url for the site you are to search again).

Here is a couple of handlers to help you with the encoding that DJ Bazzie Wazzie has come up with:

--  DJ Bazzie Wazzie
	on rawURLEncode(str)
		return do shell script "/bin/echo -n " & quoted form of str & " | php -r ' echo rawurlencode(fgets(STDIN)); '"
	end rawURLEncode
	on decode_text(this_text)
		return my rawURLDecode(this_text)
	end decode_text
	on rawURLDecode(str)
		return do shell script "/bin/echo -n " & quoted form of str & " | php -r ' echo rawurldecode(fgets(STDIN)); '"
	end rawURLDecode