search Google programmatically - search

Does anyone know if and how it is possible to search Google programmatically without entering the query in a search box? I want to double click a word in a webpage and get the google search results.

You could just link to the URL:
http://www.google.com/search?q=query+here
Pretty simple. Also, if you use .com it should automatically redirect to the user's own language-specific page, unless you specify the language in the lang= parameter.

You can create a bookmark, AKA, a bookmarklet since its actually JavaScript code in most any web browser:
javascript:window.open("https://www.google.com/search?q=" +
encodeURIComponent(window.getSelection()).substr(0,2000), "_self");
you can substitute Google for Bing or any preferred search engine, e.g.,
javascript:window.open("http://www.exalead.com/search/web/results/?q=" +
encodeURIComponent(window.getSelection()).substr(0,2000), "_self");
will open up a query at Exalead, a European competitor to Google.
Breaking it down, the JavaScript code does the following
javascript:window.open( // we will be opening a link
"https://www.google.com/search?q=" + // we will be using Google as our base search engine
encodeURIComponent( // we have to convert spaces to %20 and change rest of string to encoded URI specs
window.getSelection()).substr(0,2000), // get the selected text and grab first 2000 characters of encoded string
// since Google caps string queries at 2048 characters - you may have to shorten this slightly
"_self"); // open in same tab - use "_blank" or other desired target

Related

Disable google indexing website telephone numbers

I was presented with the task of hiding telephone numbers from Google - what that means is, we want to display them on the website and have them clickable href="tel:..." but to ensure Google does not index it and does NOT display it with the search results.
Does anyone know of any effective technique?
I was thinking of writing VueJs component, which mixes given number with some alpha characters, but this would only work with the presentation / label, the tel:... would still have to have a valid telephone number and I'm not sure if Google wouldn't pick it form the href attribute.
I think the best approach is just to hide it from bots, may be you can use something like this VueIfBot
<vue-if-bot>
This will not be visible for bots
</vue-if-bot>
or any other alternative just check the userAgent for example in php
function _bot_detected() {
return (
isset($_SERVER['HTTP_USER_AGENT'])
&& preg_match('/bot|crawl|slurp|spider|mediapartners/i', $_SERVER['HTTP_USER_AGENT'])
);
}
If you can't get userAgent, but you still want to check if this is a search engine crawler you can check user IP adress here is a list of IP Addresses of Search Engine Spiders
And finally after you successfully hide your data you can test it with User-Agent Switcher

Getting thumbnails in OpenSearchServer search results

I need an alternative to Google Custom Search for a website I look after, it has to be something that will crawl a website, index it, allow fiddling of priorities, and then allow search queries via REST or something similar and return XML or JSON etc. It needs to run on a Windows Server instance.
So, I'm up and running with http://www.opensearchserver.com/ and it seems to do the trick, but can't, for the life of me, work out how to get thumbnail images in the results? I've searched the documentation and read everything I could, but can't find out how to do this (or how to get my head around it).
I'm crawling standard web pages and they all have thumbnail meta data, which I'm assuming should be able to be parsed somehow for results and included in the JSON results?
Any pointers at all would be very helpful, thanks!
I figured this out, in case anyone else is struggling, here's how I did it. The answer is in the documentations, it's just not that simple.
Read: http://www.opensearchserver.com/documentation/faq/crawling/how_to_extract_specific_information_from_web_pages.md - it contains the method
Assume you set up a 'web crawler' index.
Assuming you're using a meta thumbnail like this:
<meta name="thumbnail" content="http://my_cdn.com/news/images/29637.jpg">
Go into Schema / Fields. Add a new field called 'thumbnail' with index no, store yes, vector no, analyser Text, copy of blank. Save that.
Now go to schema / parser list, edit HTML parser. Go to 'field mapping', now add a new regex for the thumbnail in the html. We map from the 'htmlSource' to the thumbnail' with the matching regex.
My imperfect regex (that works though) is:
htmlSource -> linked in: thumbnail -> captured by:
(?s)<meta name="thumbnail" content="(.*?)">
Now SAVE this and go to crawl/manual crawl, enter a url that has a thumbnail and then check if the field now appears in the list below when it's read. If not check your regex, and check you actually saved the HTML Parser changes.
To get the thumb in your results, simply add the fieldname to the JSON you send with the query:
"returnedFields": [ "
"url",
"thumbnail"
],

How to place search query in the URL?

With a lot of search engines, you can find the string you are searching in the URL.
However, http://drugcompare.destinationrx.com/Home.aspx does not let me do this. When I search something, the resulting URL is http://drugcompare.destinationrx.com/DrugCompare.aspx no matter what.
Is there any way I can find out whether I can search the website by adding something to the end of the URL, like "?query=searchstring" instead of using the form provided on the page? Basically I need a unique URL.
that website you pointed at uses POST to send data for its search query which means you wont be able to see or append it on the URL bar. The reason for that is either for security or the search query it generates is a complex object or too long and does not fit in a url. websites such as search engines uses GET, with that you can append your search query in the url by following the syntax it generates.

Can I redirect a query from default search box in SharePoint to a different search engine

I dont want the default results that SharePoint returns. I want the query term when entered into SharePoint search box to be redirected to a different search engine? Can I do that.
I have seen FAST ESP web parts but could not figure out how they actually transferred the query to FAST search engine.
Any help would be really appreciated!!
Add a content editor to the main search page with the following line of code
<meta http-equiv="refresh" content="5;url=http://newsearchserver">
To pass the querystring I don't have any code but I did a quick search and the following link provides information about how to get the querystring value.
http://blogs.edork.com/MikeGeyer/Lists/Posts/Post.aspx?List=c6444f02-e1a0-4a5e-b6f4-70bccdc80508&ID=36
From there you should be able to put it together and redirect to another server with the proper querystring.
Good Luck!
You could try to customize the Google Search Appliance search box for sharepoint.
http://code.google.com/apis/searchappliance/documentation/connectors/200/connector_admin/searchbox_sharepoint.html
The source code it´s on:
http://code.google.com/p/google-enterprise-connector-sharepoint/downloads/list

Sharepoint Changing URL Special characters

I have a URL stored in a Sharepoint 'Link to a document' that contains the Nordic Character 'Ø' as hex(%D8). Sharepoint is encoding the % symbol, (thus making it %25D8).
If I enter the URL directly into an address bar, it works fine.
If I don't URL encode it, I still get the same problem.
Anybody got any ideas?
So what happens if the URL is stored as 'Ø' in the URL instead of already having it encoded?
Also do you have any special process running that stores it for you? Because if you don't have any custom code interacting with this, this is probably better asked on serverfault.com.

Resources