How I Book Movie Tickets On Paytm Immediately Using A Go Script | Pilot Article
- Piyush Chhabra
- Nov 29, 2017
- 2 min read
Last month, I started learning about go ( i.e. golang ) in my free time in office.

This was just to explore a little bit about scripting as I am from completely java background and its good to have some scripting language as a tool in your pocket for some quick tasks.
To be honest, I struggled a little with the syntax for 2-3 days and finding a good IDE was also a task. Luckily, I found GoLand ( An IDE based on intelliJ Platform, free for a month ). It was still in demo phase but it was good to start with, Later I switched to LiteIDE.
I am not gonna go to technical aspects of it but I’ll name a few key concepts of go which will be needed to start any go project.
GoRoutines ( Similar to java threads, but a lot faster than them because of dynamic stack size and light weight. They are managed by GoScheduler instead of Operating System unlike Java or any other OOP language )
Go Channels ( used for synchronizing goroutines, similar as Thread pool Or Blocking Queue in Java )
Garbage Collection ( Improvised mark & sweep algorithm, also called Tri-Color Mark & Sweep which is much faster because it doesn’t halt the application while running major GC )
So here comes the interesting part. I was just looking into some open source projects on GitHub just to have an idea about the language and I found this interesting library for Web Crawling using go by antchfx
I thought of getting my hands on this. I studied a little about web scrapping & xpath Then I jumped into scripting
‘Come On, Bring It On’
I wrote a small block of code to read the html of a given url and check for a given xpath. I saw that paytm movie page is showing list of movies for a particular theater like this.
<div class="_2tt5">(3D) Justice League</div>

So if I use class=”_2tt5” as my xpath, I can get all the elements using same class which will be a list of movies and Then I can check for my keywords to find If my movie is listed or not.

And here is a small snippet to open the browser to alert me if movie is present in the list

So the code is ready, We just need to run this function test1 repeatedly with time interval

As you see, I pass the url with the xpath and movie keyword( ‘Justice’ in my case becasuse I was trying to book Justice League ). So When the theater will open the booking for movie, I will be the notified immediately as my script is running every 15 seconds iterating list.
BINGO......!!!!
Yes Its that simple. Here is full script for reference. Download and edit to change your pvr cinema link from paytm & also change your movie keyword. Run the script like
go run paytmBook.go
Questions and healthy criticism always welcome :)
留言