Scraping Google SERP is not allowed by Google long time ago. They use every methods to stop this kind of actions. There were lots of tools before in different programming languages but none of them could last long. Some tools installed on personal computer could be used but not very stable.
Also, as I knew one years ago, there is no API available for such querying.
I suggest you give up this idea to collect rank data. It's not wise to fight against Google.