28 lines
570 B
Go
28 lines
570 B
Go
package utils
|
|
|
|
import (
|
|
"net/url"
|
|
"strconv"
|
|
"time"
|
|
)
|
|
|
|
func BuildUrl(query string, page int) string {
|
|
params := url.Values{}
|
|
params.Add("q", query)
|
|
params.Add("start", strconv.Itoa(page))
|
|
|
|
now := time.Now()
|
|
twoWeeksAgo := now.AddDate(0, 0, -14)
|
|
|
|
startDate := twoWeeksAgo.Format("01/02/2006")
|
|
endDate := now.Format("01/02/2006")
|
|
|
|
tbs := "cdr:1,cd_min:" + startDate + ",cd_max:" + endDate
|
|
params.Add("tbs", tbs)
|
|
|
|
// Optional language bias
|
|
// params.Add("hl", "en")
|
|
// params.Add("lr", "lang_en")
|
|
|
|
return "https://www.google.com/search?" + params.Encode()
|
|
}
|