How to get and set values in a web-page using API Calls? Please help.

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
Sabestian Caine
Posts: 528
Joined: 12 Apr 2015, 03:53

How to get and set values in a web-page using API Calls? Please help.

07 Apr 2019, 07:40

Hello Friends..


I am trying to learn Windows API calls and I want to ask few question regarding it-

Is API calls are similar to web scrapping? As we can automate chrome and set and get values (by using selenium in chrome), that can also be done by api calls too? for example-

Look at this image-
07_04_19 @5_44_56.PNG
07_04_19 @5_44_56.PNG (33.47 KiB) Viewed 1172 times

Suppose I have to set "hello" in the red box as shown in the above image then i have to trigger these codes-

Code: Select all

driver := ChromeGet()
driver.findElementsById("keywords").item[1].SendKeys("hello")
return
 ; Note I am using selenium in chrome for automation...
ChromeGet(IP_Port := "127.0.0.1:9222") {
 driver := ComObjCreate("Selenium.ChromeDriver")
 driver.SetCapability("debuggerAddress", IP_Port)
 driver.Start()
 return driver
}

The above codes are working perfectly. If i want to perform the similar task by using windows API then what should i do?

I have watched many videos on api calls and also checked out this site to understand the basics of api calls-
http://the-automator.com/autohotkey-webinar-intro-to-webservice-api-calls/

but i am not grabbing anything. Please help.

Thanks a lot..
I don't normally code as I don't code normally.
inseption86
Posts: 203
Joined: 19 Apr 2018, 00:24

Re: How to get and set values in a web-page using API Calls? Please help.

07 Apr 2019, 09:14

Code: Select all

driver := ComObjCreate("Selenium.ChromeDriver")
driver.AddArgument("--disable-infobars")

driver.Get("https://www.autohotkey.com/boards/viewtopic.php?f=76&t=63439&p=271535&hilit=selenium#p271535")


driver.findElementsById("keywords").item[1].SendKeys("hello")



Esc::ExitApp


Exit:
    driver.Quit()
	ExitApp
	
User avatar
Sabestian Caine
Posts: 528
Joined: 12 Apr 2015, 03:53

Re: How to get and set values in a web-page using API Calls? Please help.

07 Apr 2019, 13:32

inseption86 wrote:
07 Apr 2019, 09:14

Code: Select all

driver := ComObjCreate("Selenium.ChromeDriver")
driver.AddArgument("--disable-infobars")

driver.Get("https://www.autohotkey.com/boards/viewtopic.php?f=76&t=63439&p=271535&hilit=selenium#p271535")


driver.findElementsById("keywords").item[1].SendKeys("hello")



Esc::ExitApp


Exit:
    driver.Quit()
	ExitApp
	
Hello dear inseption86. Please tell- are above codes for api call?
I don't normally code as I don't code normally.
gregster
Posts: 9002
Joined: 30 Sep 2013, 06:48

Re: How to get and set values in a web-page using API Calls? Please help.

07 Apr 2019, 23:46

The term Windows API (API simply means "application programming interface") usually refers to the lower-level workings of the Windows operating system. AutoHotkey uses this interface to do most of the things it can do via its C++ source code which wraps the Windows API for easier handling into AHK commands and functions with easier syntax - while it also allows more direct DLLCalls to the Windows API. All this has mostly not much to do with websites, webscraping or the internet - but the basic MS Windows functionalities.

What you are referring to is - in contrast - an (sometimes free, sometimes paid) interface that a specific website may offer for interaction - usually to extract data, but also sometimes to write data to the website's database.

So, of course, there is some overlap with the goal of "normal" webscraping techniques that can be used on most webpages - but in contrast to webscraping which often might be against the actual terms of service of a website and could get your IP banned, Web-APIs are usually official interfaces that allow to extract data easily and are specifically created and offered for these tasks... that means in a standardized, easily processable form and mostly with less data transfer (often in JSON format)... but you will have to refer to the specific implementation and documentation of a Webservice API to be able to use it. Often, you will also need a personal, private API key to use this service - especially if the API offers paid and/or personalized services.

To come back to your initial example - filling the AHK forum's search box: No, you cannot use the website's API for this because there is simply no such interface available to the user on autohotkey.com... like on many websites. Of course, something like this could be offered by our website but it would have to be explicitly implemented.

Perhaps read and watch the information again that you are linking to yourself. I think Joe Glines explains the most important aspects of Webservice APIs and the differences to general webscraping quite good. He also shows examples of websites that offer such API services and how to use them.

tl;dr: Windows API != Webservice APIs
User avatar
Sabestian Caine
Posts: 528
Joined: 12 Apr 2015, 03:53

Re: How to get and set values in a web-page using API Calls? Please help.

08 Apr 2019, 12:27

gregster wrote:
07 Apr 2019, 23:46
The term Windows API (API simply means "application programming interface") usually refers to the lower-level workings of the Windows operating system. AutoHotkey uses this interface to do most of the things it can do via its C++ source code which wraps the Windows API for easier handling into AHK commands and functions with easier syntax - while it also allows more direct DLLCalls to the Windows API. All this has mostly not much to do with websites, webscraping or the internet - but the basic MS Windows functionalities.

What you are referring to is - in contrast - an (sometimes free, sometimes paid) interface that a specific website may offer for interaction - usually to extract data, but also sometimes to write data to the website's database.

So, of course, there is some overlap with the goal of "normal" webscraping techniques that can be used on most webpages - but in contrast to webscraping which often might be against the actual terms of service of a website and could get your IP banned, Web-APIs are usually official interfaces that allow to extract data easily and are specifically created and offered for these tasks... that means in a standardized, easily processable form and mostly with less data transfer (often in JSON format)... but you will have to refer to the specific implementation and documentation of a Webservice API to be able to use it. Often, you will also need a personal, private API key to use this service - especially if the API offers paid and/or personalized services.

To come back to your initial example - filling the AHK forum's search box: No, you cannot use the website's API for this because there is simply no such interface available to the user on autohotkey.com... like on many websites. Of course, something like this could be offered by our website but it would have to be explicitly implemented.

Perhaps read and watch the information again that you are linking to yourself. I think Joe Glines explains the most important aspects of Webservice APIs and the differences to general webscraping quite good. He also shows examples of websites that offer such API services and how to use them.

tl;dr: Windows API != Webservice APIs

thanks a lot dear gregster for this great explanation.... thank you so much...
I don't normally code as I don't code normally.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: doodles333, Google [Bot], iamMG and 171 guests