mirror of
https://github.com/tenox7/wrp.git
synced 2025-02-16 18:30:27 +00:00
log decode error instead of bailing out
This commit is contained in:
parent
a3eb7cb69a
commit
57a107aa69
17
wrp.go
17
wrp.go
@ -8,18 +8,18 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
_ "image"
|
||||||
|
"image/gif"
|
||||||
|
"image/png"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
"bytes"
|
|
||||||
_ "image"
|
|
||||||
"image/png"
|
|
||||||
"image/gif"
|
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/chromedp/cdproto/emulation"
|
"github.com/chromedp/cdproto/emulation"
|
||||||
|
|
||||||
@ -79,15 +79,16 @@ func capture(gourl string, out http.ResponseWriter) {
|
|||||||
|
|
||||||
log.Printf("Landed on: %s, Got %d nodes\n", loc, len(nodes))
|
log.Printf("Landed on: %s, Got %d nodes\n", loc, len(nodes))
|
||||||
|
|
||||||
img, err:= png.Decode(bytes.NewReader(scrcap) )
|
img, err := png.Decode(bytes.NewReader(scrcap))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Printf("Failed to decode screenshot: %s\n", err)
|
||||||
|
fmt.Fprintf(out, "<BR>Unable to decode page screenshot:<BR>%s<BR>\n", err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
gifbuf.Reset()
|
gifbuf.Reset()
|
||||||
gif.Encode(&gifbuf, img, nil)
|
gif.Encode(&gifbuf, img, nil)
|
||||||
|
|
||||||
base, _ := url.Parse(loc)
|
base, _ := url.Parse(loc)
|
||||||
fmt.Fprintf(out, "<!-- Location: %s -->\n", base)
|
|
||||||
fmt.Fprintf(out, "<IMG SRC=\"/wrp.gif\" ALT=\"wrp\" USEMAP=\"#map\">\n<MAP NAME=\"map\">\n")
|
fmt.Fprintf(out, "<IMG SRC=\"/wrp.gif\" ALT=\"wrp\" USEMAP=\"#map\">\n<MAP NAME=\"map\">\n")
|
||||||
|
|
||||||
for _, n := range nodes {
|
for _, n := range nodes {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user