Retrieving Page Source Generated by Javascript

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Ben

Retrieving Page Source Generated by Javascript

18 Nov 2014, 01:20

Hi guys,

I asked the same question on stack overflow: http://stackoverflow.com/questions/2698 ... javascript

It seems that using the Yelp API is the recommended solution. Is there no way to do it in AHK with ComObject?

Will I have to learn Python to use the Yelp API or does AHK have some way of using the Yelp API as well?

Thanks,
Ben
User avatar
Blackholyman
Posts: 1293
Joined: 29 Sep 2013, 22:57
Location: Denmark
Contact:

Re: Retrieving Page Source Generated by Javascript

18 Nov 2014, 04:23

It can be done just fine with an IE COM object also from ahk

http://stackoverflow.com/questions/2698 ... 1#26990581

example:

Code: Select all

url := "http://www.yelp.com/search?find_desc=auto+repair&find_loc=70163&ns=1#l=g:-90.1266860962,29.9067341681,-90.0243759155,29.9959757119"

wb := ComObjCreate("InternetExplorer.Application")
wb.visible := true
wb.Navigate(url)

while wb.readyState!=4 || wb.document.readyState != "complete" || wb.busy
    continue

sleep 100

while (wb.document.getElementsByClassName("throbber-overlay")[0].style.display != "none")
    continue

msgbox % wb.document.getElementsByClassName("natural-search-result")[0].innertext
return
Hope it helps
Also check out:
Courses on AutoHotkey

My Autohotkey Blog
:dance:
Ben

Re: Retrieving Page Source Generated by Javascript

18 Nov 2014, 20:54

Amazing, that worked!

Thanks a lot, I think my issue was with:

while (ie.document.getElementsByClassName("throbber-overlay")[0].style.display != "none")
continue

I'm not even familiar enough with HTML / DOM to know about the existence of the throbber overlay, or even the existence of style.display.

My code worked as soon as I added that line.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], Lamron750 and 384 guests