带Excel VBA的Javascript(Google Adwords)

带Excel VBA的Javascript(Google Adwords),javascript,excel,vba,google-ads-api,Javascript,Excel,Vba,Google Ads Api,我非常熟悉在Excel上制作宏,但这一个让我很困惑 我有一个项目列表(>250),我需要为其列出相应的关键字。对于这个应用程序,我发现GoogleAdWords关键字生成器工具是手头最好的资源 我使用的链接是:- 在这里,我必须添加基本关键字并以CSV格式下载结果。但是,我无法通过excel自动执行此操作。我的主要问题是,当我通过VBA脚本输入搜索关键字时,文本框内的文本会发生变化,但一旦单击“获取想法”按钮,系统就会忽略新值并搜索旧值 其次,我似乎无法点击“下载”按钮 我的代码如下 'Men

我非常熟悉在Excel上制作宏,但这一个让我很困惑

我有一个项目列表(>250),我需要为其列出相应的关键字。对于这个应用程序,我发现GoogleAdWords关键字生成器工具是手头最好的资源

我使用的链接是:-

在这里,我必须添加基本关键字并以CSV格式下载结果。但是,我无法通过excel自动执行此操作。我的主要问题是,当我通过VBA脚本输入搜索关键字时,文本框内的文本会发生变化,但一旦单击“获取想法”按钮,系统就会忽略新值并搜索旧值

其次,我似乎无法点击“下载”按钮

我的代码如下

'Menu > Tools > References         (To add required libraries)
'Enable Microsoft Internet controls
'Enable Microsoft HTML Object Library


Sub Key_word()



i = 2


'Sheets("Keywords").Activate

i = i + 1


keyword_main = Cells(i, 2).Value



Dim login As Object
Dim Input_box As Object
Dim Input_box1 As Object
Dim Get_ideas As Object
Dim Dowload_all As Object
Dim Entry As Object
Dim table_res As Object
Dim image_wt As Object
Dim wsTarget As Worksheet

'Set wsTarget = ActiveWorkbook.Worksheets("raw")


Set ie = CreateObject("InternetExplorer.Application")

ie.Visible = 1 'false

ie.navigate "https://adwords.google.com/ko/KeywordPlanner/Home?__c=6147994389&__u=6746703189&authuser=0&__o=cues#search"

Do Until ie.readyState = READYSTATE_COMPLETE: DoEvents: Loop



''Set login = ie.document.getElementsByClassName("maia-button")
'Set login = ie.document.getElementById("splash-content")
'If (login <> "Nothing") Then
'login.Focus
'login.Click
''login
'End If


Set Entry = ie.document.getElementById("gwt-debug-splash-panel-resume-anchor")

If (Entry <> "Nothing") Then
Entry.Focus
Entry.Click
End If

rep = 6

While (rep = 6)

Do Until ie.readyState = READYSTATE_COMPLETE: DoEvents: Loop

'text
'"gwt-debug-keywords-text-area"
Set Input_box = ie.document.getElementById("gwt-debug-keywords-text-area")

Set Input_box1 = ie.document.getElementById("gwt-debug-category-input")

'Set Input_box = ie.document.getElementById("gwt-debug-search-button")

'Object HTMLDivElement

'Input_box.Activate

Input_box.Value = "LM339"
Input_box1.Value = "LM339"
'Input_box.Enter


'MsgBox ("1")

'Application.Wait (Now + TimeValue("00:00:20"))
'
'Do Until ie.readyState = READYSTATE_COMPLETE: DoEvents: Loop
'get ideas
'"gwt-debug-search-button-content"
Set Get_ideas = ie.document.getElementById("gwt-debug-search-button")
If (Get_ideas <> "Nothing") Then
Get_ideas.Focus
Get_ideas.Click
End If
'
'Application.Wait (Now + TimeValue("00:01:20"))
Do Until ie.readyState = READYSTATE_COMPLETE: DoEvents: Loop

'download button
'"gwt-debug-search-download-button"

''<div tabindex="0" class="ninja-button goog-inline-block goog-button goog-button-base" role="button" aria-labelledby="gwt-uid-4764" aria-haspopup="true"><input type="text" tabindex="-1" role="presentation" style="opacity: 0; height: 1px; width: 1px; z-index: -1; overflow: hidden; position: absolute;"><div class="goog-button-base-outer-box goog-inline-block"><div class="goog-button-base-inner-box goog-inline-block"><div class="goog-button-base-pos"><div class="goog-button-base-top-shadow">&nbsp;</div><div class="goog-button-base-content"><span class="aw-toolbelt-downloadButton sptd-b sptd-c">Download</span></div></div></div></div></div>
'Set Dowload_all = ie.document.getElementsByClassName("ninja-button goog-inline-block goog-button goog-button-base")
'If (Dowload_all <> "Nothing") Then
'Dowload_all.Focus
'Dowload_all.Click
'End If

'Application.Wait (Now + TimeValue("00:00:20"))


'ie.Quit

'Set ie = Nothing

rep = MsgBox("repeat", vbYesNo)

'MsgBox (rep)

Wend

'End Function
End Sub

'
”菜单>工具>参考(添加所需库)
'启用Microsoft Internet控件
'启用Microsoft HTML对象库
子关键字_单词()
i=2
'工作表(“关键字”)。激活
i=i+1
关键字_main=单元格(i,2).值
以对象身份登录
将输入框变暗为对象
尺寸输入框1作为对象
把想法当作对象
Dim Dowload_all As对象
作为对象的Dim条目
作为对象的Dim table_res
作为对象的暗淡图像
将目标设置为工作表
'Set-wsTarget=ActiveWorkbook.Worksheets(“原始”)
设置ie=CreateObject(“InternetExplorer.Application”)
即可见=1'假
即“导航”https://adwords.google.com/ko/KeywordPlanner/Home?__c=6147994389&__u=6746703189&authuser=0&__o=cues#search"
直到ie.readyState=readyState\u完成:DoEvents:Loop
''Set login=ie.document.getElementsByClassName(“maia按钮”)
'Set login=ie.document.getElementById(“启动内容”)
'如果(登录“Nothing”),则
'login.Focus
'登录。单击
''登录
"完"
Set Entry=ie.document.getElementById(“gwt调试启动面板恢复锚定”)
如果(输入“无”),则
进入,焦点
输入。单击
如果结束
代表=6
While(rep=6)
直到ie.readyState=readyState\u完成:DoEvents:Loop
"文本"
““gwt调试关键字文本区域”
设置输入框=ie.document.getElementById(“gwt调试关键字文本区域”)
设置输入\ u box1=ie.document.getElementById(“gwt调试类别输入”)
'设置输入框=ie.document.getElementById(“gwt调试搜索按钮”)
'对象HtmlLevel
'输入框。激活
输入_box.Value=“LM339”
输入框1.Value=“LM339”
'输入框。输入
'MsgBox(“1”)
'Application.Wait(现在+时间值(“00:00:20”))
'
'直到ie.readyState=readyState\u完成:DoEvents:Loop
“有想法吗
““gwt调试搜索按钮内容”
设置Get_ideas=ie.document.getElementById(“gwt调试搜索按钮”)
如果(什么都没有)那么
集中注意力
获取您的想法。单击
如果结束
'
'Application.Wait(现在+时间值(“00:01:20”))
直到ie.readyState=readyState\u完成:DoEvents:Loop
'下载按钮
““gwt调试搜索下载按钮”
“”下载
'Set Dowload_all=ie.document.getElementsByClassName(“ninja button goog inline block goog button goog button goog button base”)
'如果(所有“无”)则
“Dowload_all.Focus”
'Dowload_all.Click
"完"
'Application.Wait(现在+时间值(“00:00:20”))
”他说
'设置=无
rep=MsgBox(“重复”,vbYesNo)
'MsgBox(代表)
温德
'结束函数
端接头
'
我认为我的目标不是正确的Id,但经过数小时的反复试验和网络搜索,我没有结果

提前谢谢
Sujoy。

最终它与iMacros合作。我使用excel宏在iMacros中生成2000多行代码,然后在iMacros中运行代码以获得正确的结果

干杯, 苏乔伊

注意:-iMacros在Firefox中效果最好