Skip to content

Instantly share code, notes, and snippets.

@BharathMG
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BharathMG/0fb23790111d2aa9056f to your computer and use it in GitHub Desktop.
Save BharathMG/0fb23790111d2aa9056f to your computer and use it in GitHub Desktop.
Stop manually refreshing Movie booking sites to check if they started selling your favourite movie tickets. This prog will run forever until they open the booking.
package main
import (
"fmt"
"io/ioutil"
"net/http"
"os"
"strings"
"github.com/skratchdot/open-golang/open"
)
func main() {
// http://www.spicinemas.in/chennai/now-showing
// http://in.bookmyshow.com/
url := "url_movie_site"
needle := "movie_name"
for {
response, err := http.Get(url)
if err != nil {
fmt.Printf("%s", err)
os.Exit(1)
} else {
defer response.Body.Close()
contents, err := ioutil.ReadAll(response.Body)
s := string(contents[:])
if err != nil {
fmt.Printf("%s", err)
os.Exit(1)
}
if strings.Contains(strings.ToLower(s), needle) {
open.Run(url)
break
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment