browser

package
v0.0.0-...-d63bf21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BrowserLoad = rnt.NewSimpleFunction("BrowserLoad",
	[]string{"jar", "browser", "url", "ua"},
	func(args []rnt.Object) rnt.Object {
		jar := rnt.UnwrapNative(args[0]).(http.CookieJar)
		browser := rnt.UnwrapNative(args[1]).(Browser)
		urls := args[2].(rnt.Str).Value()
		ua := args[3].(rnt.Str).Value()

		inCookies, err := netlib.GetCookieString(jar, urls)
		if err != nil {
			panic(rnt.RaiseType(lib.ExtractorErrorType, err.Error()))
		}

		html, outCookies, err := browser.Load(urls, ua, inCookies)
		if err != nil {
			panic(rnt.RaiseType(lib.ExtractorErrorType, err.Error()))
		}

		err = netlib.SetCookies(jar, urls, outCookies)
		if err != nil {
			panic(rnt.RaiseType(lib.ExtractorErrorType, err.Error()))
		}

		return rnt.NewStr(html)
	})

BrowserLoad loads the url in the browser, keeping the cookie jar in sync.

Functions

This section is empty.

Types

type Browser

type Browser interface {
	Load(url, ua, inCookies string) (html string, outCookies string, err error)
}

Browser represents an interface towards a real browser, which can load pages evaluating JavaScript.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL