vader1972 Posted May 6, 2017 Posted May 6, 2017 Hi. I'm new to autoit and been reading for awhile. I know some basics but I can't seem to figure out one problem. At work we often do a query to medicare database but it is tiresome opening a browser every time. I want to make a simple script that will save the result of the browser into a variable without opening a browser. The URL to open. https://data.cms.gov/resource/iadr-zq3i.json?npi=1427499813 The result to store in a variable. [{"first_name":"EMILY","last_name":"DENNISON","npi":"1427499813"}] At work the NPI is always given. I know how to replace it with a variable and I know how to messagebox the result. Just don't know how to send the URL without opening a browser and putting the result in a variable. If you can provide the pseudo code or command or an example, I will truly appreciate it guys. Thank you.
alien4u Posted May 6, 2017 Posted May 6, 2017 You can take a look at WinHTTP:Win HTTP MSDN An Auto it Example here:Win HTTP AutoIt Example By Trancexxx Kind Regards Alien.
vader1972 Posted May 6, 2017 Author Posted May 6, 2017 Thank you. I tried to read it and honestly don't understand it, I guess not equip to handle programming. My profession is basically in health services. I can understand mousemove, mouseclick, variables, if else, a little bit of functions, etc but not the caliber of Trancexxx programming too complex for me. TY again.
mikell Posted May 6, 2017 Posted May 6, 2017 To make requests to this site you must register, then get a token, then include this token in the request A simple workaround could be to download the whole dataset (about 32 MB) in csv format so you can afterwards locally search inside using a simple script #Include <Array.au3> $csv = FileRead("Order_and_Referring.csv") $npi = "1427499813" $res = StringRegExp($csv, '(' & $npi & '),(\w+),(\w+)', 1) _ArrayDisplay($res)
Developers Jos Posted May 6, 2017 Developers Posted May 6, 2017 Here's a script that retrieves the JSON info from that url, to get you going : #include "WinHttp.au3" Local $id = 1427499813 Local $site = "https://data.cms.gov" Local $url = "resource/iadr-zq3i.json?npi=" & $id ; Open needed handles Local $hOpen = _WinHttpOpen() Local $hConnect = _WinHttpConnect($hOpen, $site) ; Specify the reguest: Local $hRequest = _WinHttpOpenRequest($hConnect, Default, $url, Default, Default, Default, $WINHTTP_FLAG_SECURE) ; Send request _WinHttpSendRequest($hRequest) ; Wait for the response _WinHttpReceiveResponse($hRequest) Local $jsondata = _WinHttpReadData($hRequest) ; Clean _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) ; Display retrieved json ConsoleWrite('@@ $jsondata = ' & $jsondata & @CRLF ) Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now