Exemplo n.º 1
0
func handle_content(w http.ResponseWriter, r *http.Request) {
	defer func() {
		recover()
	}()

	r.ParseForm()
	wdriver := make_webdriver()
	defer wdriver.Close()
	err := wdriver.Get(r.FormValue("url"))
	panic_error(err)
	ps, err := wdriver.PageSource()
	panic_error(err)
	time.Sleep(time.Second * 3)
	_, err = io.WriteString(w, wd.CleanHTML(ps))
	panic_error(err)
}
Exemplo n.º 2
0
func main() {
	flag.Parse()

	caps := selenium.Capabilities(map[string]interface{}{"browserName": "phantomjs"})

	wdriver, err := selenium.NewRemote(caps, config.remote)
	panic_error(err)

	wdriver.SetAsyncScriptTimeout(config.timeout)
	wdriver.SetImplicitWaitTimeout(config.timeout)
	defer wdriver.Quit()

	err = wdriver.Get(config.url)
	panic_error(err)
	if body, err := wdriver.PageSource(); err == nil {
		fmt.Println(wd.CleanHTML(body))
	}
}
Exemplo n.º 3
0
func content_clean(content string) string {
	return wd.CleanHTML(content)
}