gpt4 book ai didi

How to automate running a google search for multiple strings of content in a google sheet?(如何在谷歌工作表中自动搜索多个内容字符串?)

转载 作者:bug小助手 更新时间:2023-10-25 22:24:49 24 4
gpt4 key购买 nike



I have a spreadsheet with a list of terms that I need to run a google search for. What I want to be able to do is automate running these searches so that a new Google Chrome tab is created for each search query.

我有一个电子表格,其中包含我需要运行谷歌搜索的术语列表。我想要做的是自动运行这些搜索,以便为每个搜索查询创建一个新的Google Chrome标签。


For example:

例如:


List of Google Search Queries

谷歌搜索查询列表


Now I want to search the google search engine for each term, like 'Social Media Marketing for Small Business' and have the results open up in a new tab on Chrome.

现在我想在谷歌搜索引擎上搜索每个词,比如‘面向小企业的社交媒体营销’,然后在Chrome的一个新选项卡中打开搜索结果。


Then automate another search for the string 'What Is Social Media Marketing' and have it open in a new tab.

然后自动搜索“什么是社交媒体营销”,并在一个新的标签中打开它。


And continue doing this for all the terms in my list.

并继续对我列表中的所有术语执行此操作。


Is this possible? And how?

这可能吗?怎么做?


I tried creating a function app, but wasn't able to get it right.

我试着创建了一个功能应用程序,但做不好。


更多回答

I’d consider using textFinder

我会考虑使用TextFinder

优秀答案推荐

You can try this:

您可以尝试以下操作:



Solution 1: Using Apps Scripts



CODE 1:

代码1:


function openGoogleSearchTabs() {
var sheet = SpreadsheetApp.getActiveSheet();
var data = sheet.getRange("A2:A" + sheet.getLastRow()).getValues();

for (var i = 0; i < data.length; i++) {
var query = data[i][0];
var searchURL = "https://www.google.com/search?q=" + encodeURI(query);
var html = "<script>window.open('" + searchURL + "', '_blank');</script>";
SpreadsheetApp.getUi().showModelessDialog(HtmlService.createHtmlOutput(html), 'Opening Google Search Tabs');
Utilities.sleep(1000); // Adjust the sleep time (in milliseconds) as needed to avoid rate limiting issues
}
}

Alternatively, you can also produce a dialogue box, showing the links to each search item, like this:

或者,您也可以生成一个对话框,显示指向每个搜索项目的链接,如下所示:


enter image description here


CODE 2:

代码2:


function openGoogleSearchTabs() {
var sheet = SpreadsheetApp.getActiveSheet();
var data = sheet.getRange("A2:A" + sheet.getLastRow()).getValues();

var links = [];

for (var i = 0; i < data.length; i++) {
var query = data[i][0];
var searchURL = "https://www.google.com/search?q=" + encodeURI(query);
links.push("Search " + (i + 1) + ": <a href='" + searchURL + "' target='_blank'>" + query + "</a>");
Utilities.sleep(1000); // Adjust the sleep time (in milliseconds) as needed to avoid rate limiting issues
}

var html = links.join('<br>');
SpreadsheetApp.getUi().showModelessDialog(HtmlService.createHtmlOutput(html), 'Google Search Links');
}


Solution 2: Using a formula



=ARRAYFORMULA(IF(A2:A<>"", HYPERLINK("https://www.google.com/search?q=" & ENCODEURL(A2:A), A2:A), ""))

enter image description here


更多回答

Perfect! Thank you so much! :-) I went with option 2 and it produced exactly the results I was looking for. I love how it opens up the dialogue box for easy referencing. :-)

太棒了!太感谢你了!:-)我选择了选项2,它产生了我想要的结果。我喜欢它打开对话框以便于参考的方式。:-)

You're welcome. I've also added a solution using a formula (in B2). Please read this: What should I do when someone answers my question? at this =>> link

不用谢。我还使用公式添加了一个解决方案(在B2中)。请阅读以下内容:当有人回答我的问题时,我应该怎么做?在此=>>链接

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com