Last active
August 29, 2015 14:14
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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