diff --git a/README.md b/README.md index 02dd491..07e3c72 100644 --- a/README.md +++ b/README.md @@ -12,14 +12,13 @@ A HTTP proxy server that allows to use historical and obsolete web browsers on t * gif with Floyd–Steinberg dithering * random image addressing * resolve relative links -* simple scrolling +* paginated scrolling * google search on input not starting with ^http ## Todo * ISMAP * net/url: invalid control character in URL on Windows * configurable color palete and quantization -* paginated scrolling * real http proxy support * option to encode as png/jpeg * padded box model coordinates @@ -27,6 +26,4 @@ A HTTP proxy server that allows to use historical and obsolete web browsers on t * chromedp logging, timeout, non-headless flags ## Python version -Check [master branch](https://github.com/tenox7/wrp/tree/master) for "stable" Python-Webkit version. - - +Check [master branch](https://github.com/tenox7/wrp/tree/master) for "stable" Python-Webkit version. \ No newline at end of file diff --git a/wrp.go b/wrp.go index fbfa18b..cbd0d22 100644 --- a/wrp.go +++ b/wrp.go @@ -50,7 +50,12 @@ func pageServer(out http.ResponseWriter, r *http.Request) { istr = "" i = false } - y, _ := strconv.ParseInt(r.FormValue("y"), 10, 64) + p, _ := strconv.ParseInt(r.FormValue("p"), 10, 64) + if r.FormValue("pg") == ">>" { + p++ + } else if r.FormValue("pg") == "<<" { + p-- + } w, _ := strconv.ParseInt(r.FormValue("w"), 10, 64) if w < 10 { w = 1024 @@ -72,13 +77,15 @@ func pageServer(out http.ResponseWriter, r *http.Request) { fmt.Fprintf(out, "Width: \n", w) fmt.Fprintf(out, "Height: \n", h) fmt.Fprintf(out, "Scale: \n", s) - fmt.Fprintf(out, "Scroll: \n", y) + fmt.Fprintf(out, "Page: \n", p) + fmt.Fprintf(out, " %d \n", p) + fmt.Fprintf(out, ">\"> \n") fmt.Fprintf(out, "

") if len(u) > 4 { if strings.HasPrefix(u, "http") { - capture(u, w, h, s, y, out) + capture(u, w, h, s, p, out) } else { - capture(fmt.Sprintf("http://www.google.com/search?q=%s", url.QueryEscape(u)), w, h, s, y, out) + capture(fmt.Sprintf("http://www.google.com/search?q=%s", url.QueryEscape(u)), w, h, s, p, out) } } else { fmt.Fprintf(out, "No URL or search query specified") @@ -105,7 +112,7 @@ func haltServer(out http.ResponseWriter, req *http.Request) { os.Exit(0) } -func capture(gourl string, w int64, h int64, s float64, y int64, out http.ResponseWriter) { +func capture(gourl string, w int64, h int64, s float64, p int64, out http.ResponseWriter) { var nodes []*cdp.Node ctxx := chromedp.FromContext(ctx) var pngbuf []byte @@ -119,7 +126,7 @@ func capture(gourl string, w int64, h int64, s float64, y int64, out http.Respon err := chromedp.Run(ctx, emulation.SetDeviceMetricsOverride(w, h, s, false), chromedp.Navigate(gourl), - chromedp.Evaluate(fmt.Sprintf("window.scrollTo(0, %d);", y), &res), + chromedp.Evaluate(fmt.Sprintf("window.scrollTo(0, %d);", p*int64(float64(h)*float64(0.9))), &res), chromedp.Sleep(time.Second*1), chromedp.CaptureScreenshot(&pngbuf), chromedp.Location(&loc), @@ -165,7 +172,7 @@ func capture(gourl string, w int64, h int64, s float64, y int64, out http.Respon if err != nil { continue } - target := fmt.Sprintf("/?url=%s&w=%d&h=%d&s=%1.2f&y=%d", tgt, w, h, s, y) + target := fmt.Sprintf("/?url=%s&w=%d&h=%d&s=%1.2f&", tgt, w, h, s) // no page# here if len(b.Content) > 6 && len(target) > 7 { fmt.Fprintf(out, "\"%s\"\n",