所以我想在我的网站上插入一个搜索表单,将用户的查询重定向到Google搜索。
我过去常常能够这样做:
<form role="search" method="get" id="searchform" class="searchform" action="http://www.google.co.uk/search?hl=en-GB&source=hp&q=">
<div id="gform">
<label class="screen-reader-text" for="s"></label>
<input type="text" value="" name="s" id="s">
<input type="submit" class="btn fa-input" value="" style="font-family: FontAwesome;">
</div>
</form>
然而,这不再适用。我猜测这是因为Google更改了搜索网址,但我无法通过使用Google的当前网址来复制此效果。
知道如何解决这个问题吗?
答案 0 :(得分:2)
大家好,我自己已经解决了这个问题
<div id="gform">
<label class="screen-reader-text" for="s"></label>
<input type="text" value="" name="q" id="s">
<input type="submit" class="btn fa-input" value="" style="font-family: FontAwesome;">
</div>
name="q"
。这是您进行谷歌搜索工作所需要的;基本上这是因为谷歌希望q
作为名称
答案 1 :(得分:1)
此代码段会创建一个简单的Google搜索框
<form action="http://www.google.com/search" method="get">
<input type="text" name="q"/>
<input type="submit" value="search" />
</form>