Here is something that checks results I haven't looked at the code in a minute but I believe it still works, it might point you in the right direction.
comment("check for domain and print out results with positions")
ui drop down("Check Pages:", "1,2,3,4,5,6,7,8,9,10", #loops)
clear table(&rankings)
ui text box("Keyword:", #input_keyword)
ui text box("Domain:", #domain)
plugin command("HTTP post.dll", "Page Scraper", "https://www.google.com/setprefs?sig=0_99_9Ba26GvHykubSeuKp228oSs0%3D&hl=en&safeui=images&suggon=1&num=100&newwindow=0&q=&prev=https%3A%2F%2Fwww.g