removed random geolocation; instead, a fixed US location is used
This commit is contained in:
parent
d9d0301548
commit
2757fc8d80
1 changed files with 8 additions and 9 deletions
|
@ -2,7 +2,6 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -75,7 +74,7 @@ func buildSearchURL(query, safe, lang string, page, resultsPerPage int) string {
|
||||||
uuleParam = ""
|
uuleParam = ""
|
||||||
} else {
|
} else {
|
||||||
// Use random geolocation
|
// Use random geolocation
|
||||||
glParam, uuleParam = getRandomGeoLocation()
|
glParam, uuleParam = "us", "us"
|
||||||
}
|
}
|
||||||
|
|
||||||
startIndex := (page - 1) * resultsPerPage
|
startIndex := (page - 1) * resultsPerPage
|
||||||
|
@ -87,15 +86,15 @@ func buildSearchURL(query, safe, lang string, page, resultsPerPage int) string {
|
||||||
url.QueryEscape(query), safeParam, langParam, glParam, uuleParam, startIndex)
|
url.QueryEscape(query), safeParam, langParam, glParam, uuleParam, startIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getRandomGeoLocation() (string, string) {
|
// func getRandomGeoLocation() (string, string) {
|
||||||
countries := []string{"us", "ca", "gb", "fr", "de", "au", "in", "jp", "br", "za"}
|
// countries := []string{"us", "ca", "gb", "fr", "de", "au", "in", "jp", "br", "za"}
|
||||||
randomCountry := countries[rand.Intn(len(countries))]
|
// randomCountry := countries[rand.Intn(len(countries))]
|
||||||
|
|
||||||
glParam := "&gl=" + randomCountry
|
// glParam := "&gl=" + randomCountry
|
||||||
uuleParam := ""
|
// uuleParam := ""
|
||||||
|
|
||||||
return glParam, uuleParam
|
// return glParam, uuleParam
|
||||||
}
|
// }
|
||||||
|
|
||||||
func parseResults(doc *goquery.Document) []TextSearchResult {
|
func parseResults(doc *goquery.Document) []TextSearchResult {
|
||||||
var results []TextSearchResult
|
var results []TextSearchResult
|
||||||
|
|
Loading…
Add table
Reference in a new issue