Hero Image
Take Screenshots with Selenium in Go

Take Screenshots with Selenium in Go package main import ( "fmt" log "github.com/sirupsen/logrus" "github.com/tebeka/selenium" "io/ioutil" ) const ( chromeDriverPath = "/usr/local/bin/chromedriver" port = 9515 ) func main() { var opts []selenium.ServiceOption selenium.SetDebug(false) service, err := selenium.NewChromeDriverService(chromeDriverPath, port, opts...) if err != nil { panic(err) // panic is used only as an example and is not otherwise recommended. } defer service.Stop() caps := selenium.Capabilities{"browserName": "chrome"} // Full-page screenshot // Get page width/height, resize the browser window, then take a screenshot. // Note: only headless mode allows arbitrary window sizes; otherwise the max height cannot exceed your screen resolution. // chromeCaps := chrome.Capabilities{ // Path: "", // Args: []string{ // "--headless", // }, // } // caps.AddChrome(chromeCaps) wd, err := selenium.NewRemote(caps, fmt.Sprintf("http://localhost:%d/wd/hub", port)) if err != nil { panic(err) } defer wd.Quit() // ExecuteScript can run JavaScript. The return value is interface{}, so assert to float then convert to int. // height, _ := wd.ExecuteScript("return document.body.parentNode.scrollHeight", nil) // var realHeight = int(height.(float64)) // Then set the window size. // wd.ResizeWindow("", 1920, realHeight) if err := wd.Get("https://github.com/tgbot-collection/archiver"); err != nil { panic(err) } screenshot, err := wd.Screenshot() if err != nil { log.Errorln(err) } ioutil.WriteFile("screenshot.png", screenshot, 0644) } Full-page screenshot Get the page width/height, resize the browser window accordingly, and then take the screenshot. Note that only headless mode allows arbitrary window sizes; otherwise the maximum height cannot exceed your display resolution.

Hero Image
Ancient Time Units

Ancient Time Units Twelve Double-Hour Time Reference Time Period Ancient Name Modern Time Initial / Exact Time Other Names (full) 子時 夜半 23:00-01:00 子初 23:00 子正 00:00 子夜、中夜、午夜、夜分、夜半、未旦、宵分、未央 丑時 雞鳴 01:00-03:00 丑初 01:00 丑正 02:00 荒雞 寅時 平旦 03:00-05:00 寅初 03:00 寅正 04:00 平明、旦明、黎明、早旦、日旦、昧旦、騎旦、早晨、早夜、早朝、昧爽、旦日、旦時 卯時 日出 05:00-07:00 卯初 05:00 卯正 06:00 日上、日生、日升、日始、日晞、旭日、破曉 辰時 食時 07:00-09:00 辰初 07:00 辰正 08:00 早食、宴食、蚤食 巳時 隅中 09:00-11:00 巳初 09:00 巳正 10:00 日隅、禺中、日禺 午時 日中 11:00-13:00 午初 11:00 午正 12:00 日正、日午、日高、正午、中午、亭午、日當午、平午、平晝 未時 日昳 13:00-15:00 未初 13:00 未正 14:00 日昃、日仄、日側、日跌、日斜、日映、日央 申時 晡時 15:00-17:00 申初 15:00 申正 16:00 餔時、日餔、日晡、日鋪、日稷、日夕、夕食 酉時 日入 17:00-19:00 酉初 17:00 酉正 18:00 日沒、日沉、日西、日落、日逝、日晏、日旴、日晦、傍晚 戌時 黃昏 19:00-21:00 戌初 19:00 戌正 20:00 日夕、日末、日暮、日晚、日闇、日墮、日暗、日曛、曛黃 亥時 人定 21:00-23:00 亥初 21:00 亥正 22:00 定昏、夤夜 Night Watches In the Han dynasty, palace guards rotated in five shifts called “five watches”. Thus, a night was divided into five watches, each equal to one time period (double-hour). Xu time is the first watch, Hai time is the second, Zi time the third, Chou time the fourth, and Yin time the fifth.