Is it possible to obtain the search query from Google search results page, given the page's URL? I've noticed that the search query is usually shown in the URL, but the format of the URL can sometimes be slightly confusing.
For example, one search results URL for the search stackoverflow is
https://www.google.com/webhp?hl=en&tab=ww#hl=en&tbo=d&sclient=psy-ab&q=stackoverflow&oq=stackoverflow&gs_l=hp.3..35i39l2j0l2.920.3338.0.3436.13.12.0.0.0.0.310.1216.10j1j0j1.12.0.les%3B..0.0...1c.1.3.psy-ab.OH00abu0aqs&pbx=1&bav=on.2,or.r_gc.r_pw.r_cp.r_qf.&bvm=bv.42452523,d.dmQ&fp=8bb62755c027473d&biw=1366&bih=631
Another URL for the same search string is
https://www.google.com/search?btnG=1&pws=0&q=stackoverflow.
Would there be any way to obtain the Google search query from all types of Google search result URLs using JavaScript?
Usually the search term is the URL parameter 'q' of Google.
Check here on how to do this Extract keyword from Google search in Javascript
Related
I have a webpage where it has its own search form that is using the "q" as the GET parameter, when a user try to use that search if there's no result found on that search, I will display the Google Custom Search and let them Google instead. However, when my URL is mydomain.com/?q=test , the Google Custom Search will autopopulate its search field as "test" and trigger the Google search result as well on the same webpage.
I prefer Google custom search not to be autopopulated because I am afraid if this break the adsense policies. But I can't avoid it, my webpage already been using the "q" as parameter, it's not an option for me to change to another parameter.
So does that break adsense policy, if so, how to avoid autopopulate ?
Thank
You can change the default query parameter from the control panel at Search features > Advanced > WebSearch Settings > Query Parameter Name.
See https://support.google.com/programmable-search/answer/3037004
I want to add such a search bar in my site that users search my site and they can get instant result though live search like wikipedia. How can be done this job?
What you want is an ajax request which queries a php file and search for the keyword in your db and return the topic to be displayed as search predictions. Here is a good example that you can try it out.
https://www.w3schools.com/php/php_ajax_livesearch.asp
In a nutshell, you need an endpoint that you can call each time you change the input with the current results. That endpoint would then spit back out search results which you could render to show the user.
I'm trying to retrieve the web page content of Bing Images for a specific query.
I'm currently communicating with Bing through the following URL (in case of a sample foo search), from curl command line tool:
curl http://www.bing.com/images/search?q=foo
Since the safe search filter is enabled by default, I'd need to disable it.
How can I do that?
I know that direct API access would be preferable, but I need to bypass them and retrieve the entire web page.
I saw that from the web page, the safe search is disabled through Ajax calls.
What URL should I contact to make a search with safe search disabled?
The correct solution is to use the query parameter safeSearch=off, like
curl http://www.bing.com/images/search?q=foo&safeSearch=off
This is not documented anywhere I could find.
Add &adlt_set=off to the Bing Search url to close SafeSearch.
&adlt_set=moderate to filter adult images and videos but not text from your search results.
&adlt_set=Strict to filter out adult text, images, and videos from your search results.
The solution is simply to add &safesearch=off to the search URL.
I'm trying to build a Chrome extension and clearly I'm a n00b.
I want to display some links on the right side of Google's result page, based on the query the user has searched.
But I'm just not able to get hold of the user query string!. I cannot depend on parsing URL since, the URL remains the same even though the user has made a second search. Let me clarify with a use case:
User enters a search query "testing time" via omnibox and clicks on
enter. URL has now become
"https://www.google.co.in/search?q=testing+time"
Now from within the results page, user changes the query to "testing again" and clicks on enter. The URL will remain what it was earlier, "https://www.google.co.in/search?q=testing+time".
How then shall I get hold of the query string?
For the case 2 mentioned by you, you should see #q=testing+again at the end of the URL.
You can get it via
location.hash.split("=").pop(); //you might have to unescape it
OR alternatively you can read the new query from the text box itself. (I would prefer this method)
document.getElementsByName("q")[0].value
I use following sample URL pattern to search pattern on my web site.
http://www.mysite.com/search/someword
No query strings, just clean URL..
How can set this URL to google analytics site search system?
In theory, you should be able to create a profile filter to convert the URLs to use a query string. In practice, it turns out it's not possible, because Site Search gets processed before filters get processed.
Instead, what I've found that works is to just manipulate it in JavaScript so that you "fake" a query string directly from the browser.
Something like:
if(!location.pathname.match(/^\/search/)){
_gaq.push(["_trackPageview"]);
}
else{
_gaq.push(["_trackPageview", location.pathname.replace("/search/","/search?q=")]);
}
This would "fake" a query string with a key of q that you could then easily use the Site Search feature with.