browser

package
v0.0.0-...-195b10e Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Browser

type Browser struct {
	selenium.WebDriver
	// contains filtered or unexported fields
}

Browser simulates a simple web browser using Selenium

func NewBrowser

func NewBrowser() (*Browser, error)

NewBrowser returns a new Browser object. In the background, it initializes a new Selenium service and uses Firefox as the browser.

func (*Browser) Close

func (b *Browser) Close()

Close will clean up and close the Browser. Must be called when the program us done using the Browser.

func (*Browser) GetSource

func (b *Browser) GetSource(cssSelect string) (WebsiteSource, error)

GetSource returns the source code of the current webpage If cssSelect is empty, the whole page is returned. If it is specified, the source code of the element pointed at by cssSelect will be returned.

func (*Browser) NavigateTo

func (b *Browser) NavigateTo(url string) error

NavigateTo navigates to the specified url

type WebsiteSource

type WebsiteSource struct {
	URL       string
	Source    string
	CSSSelect string
}

WebsiteSource represents the source code of a website

func GetAllWebsitesFromFiles

func GetAllWebsitesFromFiles() ([]WebsiteSource, []string, error)

GetAllWebsitesFromFiles reads the folder savedWebsites and returns all the websites in there. First argument returned is the websites themselves, and the second is the name of the file themselves.

func (*WebsiteSource) WriteToFile

func (w *WebsiteSource) WriteToFile() error

WriteToFile writes this WebsiteSource to a file under the folder savedWebsites

Jump to

Keyboard shortcuts

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