【问题标题】:Search for particular link in google search在谷歌搜索中搜索特定链接
【发布时间】:2018-12-04 19:58:10
【问题描述】:
<body>

<form action="http://google.com/search" method="GET">
    <label for="keyword">Keyword: </label>
    <input type="text" name="q" placeholder="Search Keyword" id="keyword">

    <label for="site">Site: </label>
    <input type="text" placeholder="Site" id="site">


    <input type="submit" value="Google Search" onclick="well();">
</form>

<script >
    function well(){
        var something = document.getElementById("site").value;
        alert(something);
    }
</script>

所以我想要的是:

  1. 在第一个输入中,您搜索要在 google 上搜索的关键字。

  2. 在第二个输入中,您输入要搜索的链接以查看它是否出现在第一页上

  3. 单击按钮使其搜索并使我的脚本在该页面上运行。

    var myList = [];
    var x = document.querySelectorAll("#rso h3");
    for(var i=0; i<x.length; i++){
    myList.push(x[i].textContent);
    }
    console.log(myList);
    

上面的代码可以找到h3标签。

但是我怎样才能通过点击按钮来实现呢?

【问题讨论】:

    标签: javascript google-search


    【解决方案1】:

    带有 google.com 网址的表单操作会将您的用户从您的网站导航到该搜索。为了捕获搜索结果,您需要使用Google Search API。相关问题here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-11-20
      • 1970-01-01
      • 1970-01-01
      • 2021-08-23
      • 2012-08-19
      • 1970-01-01
      • 1970-01-01
      • 2017-08-01
      相关资源
      最近更新 更多