Javascript (Google Adwords) with Excel VBA

I am well versed with making macros on Excel but this one has me stumped.

I have a list of items (>250) for which I need to make a list of corresponding keywords. For this application I have found the Google Adwords Keyword generator tool to be the best resource at hand.

The link that I am using is:- https://adwords.google.com/ko/KeywordPlanner/Home?__c=6147994389&__u=6746703189&authuser=0&__o=cues#start

Screenshot

Here I have to add the basic Keyword and download the result in CSV format. However I am not able to automate this via excel. My major issue is that when I enter my search keyword via the VBA script, the text inside the text box changes but once the button "Get Ideas" is clicked, the system ignores the new value and searches on the older value.

Secondarily I can't seem to click the "Download" button.

My code is as below.

'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

'

I think that I am not targeting the correct Id's but after hours of trial and error and web searches, I have no results.

Thanks in Advance Sujoy.

Answers


Finally it worked with iMacros. I used excel macros to generate a 2000+ line code in iMacros and then ran the code in iMacros to get the proper results.

Cheers, Sujoy.

Note:- iMacros works best in Firefox.


Need Your Help

Creating a Smarty variable in a template from smarty variables

security templates hash smarty

I am trying to create a hash using a salt (from a global file) and variables from the template form. I need to create the hash in the template. Perhaps i am missing something obvious, but I cannot ...