avct / uasurfer

Go package for fast and reliable abstraction of browser user agent strings.
Other
337 stars 76 forks source link

Google search console mobile useragent detected as computer #67

Open metalwolf opened 3 years ago

metalwolf commented 3 years ago

The google search console bot for mobile is detected as computer wich makes google believe the mobile sites are for PC.

func main() {

    useragent := "Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.92 Mobile Safari/537.36 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"

    ua := uasurfer.Parse(useragent)
    fmt.Printf("Useragent: %s\n Result: %+v\n", useragent, ua)
}

Output:

Useragent: Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.92 Mobile Safari/537.36 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)
 Result: &{Browser:{Name:BrowserGoogleBot Version:{Major:0 Minor:0 Patch:0}} OS:{Platform:PlatformBot Name:OSBot Version:{Major:6 Minor:0 Patch:1}} DeviceType:DeviceComputer}

Could be good to detect google bots as computer or mobile as it should be

Going to fork to modify this