【问题标题】:Google Search with RoR, how make it works?带有 RoR 的 Google 搜索,它是如何工作的?
【发布时间】:2011-12-22 06:13:00
【问题描述】:

我是 RoR 的新手,我想知道如何根据我的项目使用字段进行 google 搜索,有人知道我该怎么做吗?

我的 application.html.haml 中有代码:

 %form#search
  %input

我该如何实现?

【问题讨论】:

  • 这样我可以返回站点搜索google,如果返回站点环境内的页面??喜欢其他 index.html.haml 页面吗??

标签: ruby-on-rails ruby google-search google-search-api


【解决方案1】:

将表单的action 设置为http://www.google.com/search,将method 设置为get,并将input 字段命名为q。类似于以下内容:

%form#search(action="http://www.google.com/search" method="get")
  %input(type="text" name="q")
  %input(type="submit")

结果将是 google 搜索的正常 URL,并显示结果:

http://www.google.com/search?q=term1+term2

【讨论】:

  • 这样我可以返回站点搜索google,如果我返回站点环境内的页面??喜欢其他 index.html.haml 页面吗??
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-06-25
  • 1970-01-01
  • 1970-01-01
  • 2014-04-19
  • 1970-01-01
相关资源
最近更新 更多