//RtScraper function takes the movie name and year(an optional argument) as arguments and returns the rating from rt
RtScraper function takes the movie name and year(an optional argument) as arguments and returns the rating from rt
// RtScraper function takes the movie name and year ( an optional argument ) as arguments and returns the rating from rt
func RtScraper(mname string, year string) string {
	movieName := strings.Replace(mname, " ", "_", 9)
	urlis := "https://www.rottentomatoes.com/m/" + movieName
	if len(year) == 4 {
		urlis = urlis + "_" + year
	}
	doc, err := goquery.NewDocument(urlis)
	if err != nil {
		fmt.Println("Error occurred")
	}
	rating := strings.TrimSpace(doc.Find("#tomato_meter_link > span:nth-child(2)").Text())
	if len(rating) == 0 {
		return "-1"
	} else if len(rating) > 4 {
		return rating[:3]
	} else {
		return rating[:2]
	}
}
func RtScraper ( mname string , year string ) string { movieName := strings . Replace ( mname , " " , " " , 9 ) urlis := " " + movieName if len ( year ) == 4 { urlis = urlis + " " + year } doc , err := goquery . NewDocument ( urlis ) if err != nil { fmt . Println ( " " ) } rating := strings . TrimSpace ( doc . Find ( " " ) . Text ( ) ) if len ( rating ) == 0 { return " " } else if len ( rating ) > 4 { return rating [ : 3 ] } else { return rating [ : 2 ] } }
RtScraper function takes the movie name and year(an optional argument) as arguments and returns the rating from rt
RtScraper function takes the movie name and year ( an optional argument ) as arguments and returns the rating from rt