K
K
koltykov2016-08-31 17:19:03
Yandex
koltykov, 2016-08-31 17:19:03

How to automatically submit a form from Yandex.Search?

I decided to embed a search from Yandex on my site , instead of Sphinx.
Everything on the page works great. But the site uses a search bar in the header on all pages. Previously, the search string was passed to the form on the search page and submitted.
And now I have a third-party code:

<div class="ya-site-form ya-site-form_inited_no" onclick="return {'action':'http://site.net/search.php','arrow':false,'bg':'transparent','fontsize':13,'fg':'#000000','language':'ru','logo':'rb','publicname':'Поиск по site.net','suggest':true,'target':'_self','tld':'ru','type':2,'usebigdictionary':false,'searchid':444555,'input_fg':'#000000','input_bg':'#efefef','input_fontStyle':'normal','input_fontWeight':'bold','input_placeholder':'','input_placeholderColor':'#000000','input_borderColor':'#000000'}"><form action="https://yandex.ru/search/site/" method="get" target="_self" accept-charset="utf-8"><input type="hidden" name="searchid" value="444555"/><input type="hidden" name="l10n" value="ru"/><input type="hidden" name="reqenc" value=""/><input type="search" name="text" value=""/><input type="submit" value="Найти"/></form></div><style type="text/css">.ya-page_js_yes .ya-site-form_inited_no { display: none; }</style><script type="text/javascript">(function(w,d,c){var s=d.createElement('script'),h=d.getElementsByTagName('script')[0],e=d.documentElement;if((' '+e.className+' ').indexOf(' ya-page_js_yes ')===-1){e.className+=' ya-page_js_yes';}s.type='text/javascript';s.async=true;s.charset='utf-8';s.src=(d.location.protocol==='https:'?'https:':'http:')+'//site.yandex.net/v2.0/js/all.js';h.parentNode.insertBefore(s,h);(w[c]||(w[c]=[])).push(function(){Ya.Site.Form.init()})})(window,document,'yandex_site_callbacks');</script>

I tried to submit the form, provided that the search string from other pages
is set. But it is passed without parameters, and then it is displayed in a new window, and not on my site.
How to correctly send this form to Yandex with the parameters specified in return {'action':'http:...........

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey, 2016-08-31
@reaferon

Once I also took care of customizing the search from Yandex. As a result, he spat on this matter and began to use Yandex.XML . We send a request to Yandex, get a response in XML format, display it on our site. Very convenient, but there is one drawback: limits on the number of daily requests. And the number of limits cannot be increased even for a fee (at least officially). I recommend, in general, if the daily number of requests is less than 1000.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question