本日1件のお問い合わせがありました。

✉️FIELDにお問い合わせ

マーケティングSEO

googleサジェストを生成するAppleScript完全版

こんにちは山本です

前回もgoogleサジェストを生成するextentionの話をしましたが
やはり皆さんが求めているのは
コピペして実行ですぐに生成できるような簡単なものかと思いまして、
今回はそれを作りました。

Macの人はcommandを押しながらスペースキーを押すと
Macの中にあるすべてのファイルを検索できますので
そこで「スクリプト」と検索すると
AppleScriptのアプリケーションが見つかります。

それを開いてください。

なんの変哲もないただのエディタが開きます。

そして次にデスクトップにsearchkeyword.txtというファイルを作り
検索したいワードを1行に一つ書いていってください

今回は

これを保存しておきました。

そして先ほどのエディタに

-- スタート時間を記録
set startTime to (current date)

-- 検索キーワードファイルのパス
set keywordFile to ((path to desktop folder as text) & "searchkeyword.txt")

-- UTF-8でファイルを読み込む(日本語対応)
set keywordData to read file keywordFile as «class utf8»
set keywordList to paragraphs of keywordData

-- 無限ループ開始(3分経過で脱出)
repeat
	set currentTime to (current date)
	if (currentTime - startTime) > 180 then
		exit repeat
	end if
	
	repeat with searchKeyword in keywordList
		set currentTime to (current date)
		if (currentTime - startTime) > 180 then
			exit repeat
		end if
		
		-- クリップボードにキーワードをコピー
		set the clipboard to searchKeyword
		
		-- Chrome シークレットモードで Google を開く
		do shell script "open -na 'Google Chrome' --args --incognito 'https://www.google.com'"
		
		-- ★ランダム:ページ読み込み待機(10〜12秒)
		delay (10 + (random number from 0 to 2))
		
		tell application "System Events"
			-- ペースト → ランダム待機(3.0〜3.3秒)→ Enter
			keystroke "v" using {command down}
			delay (3 + (random number from 0.0 to 0.3))
			key code 36
		end tell
		
		-- ★ランダム:検索結果の待機(5〜6秒)
		delay (5 + (random number from 0 to 1))
		
		-- スクロール(↓キー x3)間にランダムな待機(0.3〜0.6秒)
		tell application "System Events"
			key code 125
			delay (0.3 + (random number from 0.0 to 0.3))
			key code 125
			delay (0.3 + (random number from 0.0 to 0.3))
			key code 125
			delay (0.3 + (random number from 0.0 to 0.3))
		end tell
		
		-- ★ランダム:ページ観察時間(2〜3秒)
		delay (2 + (random number from 0 to 1))
		
		-- ✅ シークレットウィンドウのみ閉じる
		tell application "Google Chrome"
			repeat with w in windows
				try
					set isIncognito to execute w javascript "window.chrome && chrome.extension ? false : true"
					if isIncognito is "true" then
						close w
					end if
				end try
			end repeat
		end tell
		
		-- ★ランダム:次までの待機(5〜6秒)
		delay (5 + (random number from 0 to 1))
	end repeat
end repeat

display dialog "3分間の検索が完了しました。" buttons {"OK"} default button "OK"

これをコピペしてください。

そして、

ここをクリックしてください

すると….

しばらく経つと自動で検索をしていってくれます。

googleはセレニウムなどで検索してもブラウザごとに一意に与えられるキーがパラメーターに付くため、これがないとサジェストが生成されません。

そのため本当のブラウザを動かしてしまうのが一番です。

サジェストは検索ボリュームに対してN%(企業秘密)の回数をN個のネットワークIPで検索すると生成されますから、地理的に離れたmacにこのスクリプトを入れて実行すれば
生成されます。

とてもシンプルですね。

Yamamoto Yuya

プロフェッショナルとしての高いスキルと知識を持ち、誠実さと責任感を大切にする。常に向上心を持ち、新たな挑戦にも積極的に取り組む努力家。