【问题标题】:How do I create a link to google image search via HTML form?如何通过 HTML 表单创建指向 Google 图片搜索的链接?
【发布时间】:2020-11-27 13:54:43
【问题描述】:

尝试使用 HTML 表单制作 Google 图片搜索克隆,在搜索字段中输入文本后,它会将您直接带到 Google 图片搜索结果页面。

这是我正在使用的代码:

<body>
    <form action="https://google.com/search">
        <input type="text" name="q">
        <input type="submit" value="Google Search">
    </form>
</body>

正常谷歌搜索,如何改成谷歌图片搜索结果页面?

【问题讨论】:

    标签: html


    【解决方案1】:

    您必须更改操作,如下所示:

    <form method="get" action="http://images.google.com/images">
      <input type="text" name="q" />
      <input type="submit" value="Google Search" />
    </form>

    【讨论】:

    • 太棒了,谢谢。我不知道我是怎么错过的。我正在尝试类似 &lt;form method="get" action="https://www.google.com/search?tbm=isch&amp;"&gt; &lt;input type="text" name="q" /&gt; &lt;input type="submit" value="Google Search" /&gt; &lt;/form&gt; 的东西,如果我想这样做,我如何找到 url,因为我感觉很幸运搜索?
    • 由于在 Google 上搜索图像时没有“我感觉很幸运”选项,我假设您希望它用于文本搜索。在这种情况下,您必须将操作更改为:&lt;form method="get" action="http://images.google.com/search"&gt;,然后更改当前输入或添加新输入,如下所示:&lt;input type="submit" name="btn2" value="I am Feeling Lucky" class="button"&gt;
    • 是的,想通了 :) 谢谢!
    【解决方案2】:

    谷歌图片搜索链接的格式如下 https://www.google.com/search?q=```query```&tbm=isch

    每个参数 q 和 tbm 都需要输入标签,但 tbm 不需要任何用户输入。 'GET_parameter_name=value' 在提交按钮之前的每个输入标记都附加了 '&'。

            
    <form action="https://www.google.com/search">
      <input type="text" name="q" id="box">
      <input type="hidden" name="tbm" value="isch">
      <input type="submit" value="Image Search" >
    </form>

    来源: https://stenevang.wordpress.com/2013/02/22/google-advanced-power-search-url-request-parameters/

    https://www.xul.fr/javascript/parameters.php

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-07-20
      • 1970-01-01
      • 2013-09-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多