starlib: Index | Files

package bsoup

import ""

Package bsoup defines a beautiful-soup-like API for working with HTML documents in starlark

outline: bsoup
  bsoup defines a beautiful-soup-like API for working with HTML documents
  path: bsoup
        find(name, attrs, recursive, string, **kwargs)
          retrieve the first occurance of an element that matches arguments passed to find.
          works similarly to [node.find()](
        find_all(name, attrs, recursive, string, limit, **kwargs)
          retrieves all descendants that match arguments passed to find_all.
          works similarly to [node.find_all()](
          get a dictionary of element attributes
          works similarly to [node.attrs](
          gets the list of children of an element
          works similarly to [soup.contents](
          gets a single child element with the given tag name
          works like accessing a node [using its tag name](
          gets the parent node of an element
          works like [node.parent](
          gets the next sibling of an element
          works like [node.next_sibling](
          gets the previous sibling of an element
          works like [node.prev_sibling](
          all the text in a document or beneath a tag, as a single Unicode string:
          works like [soup.get_text](
    parseHtml(html string) SoupNode
      parseHtml parses html from a string, returning the root SoupNode


Package Files

bsoup.go doc.go


const ModuleName = ""

ModuleName defines the name for loading this module, using `load('', 'bsoup')

func AsString Uses

func AsString(x starlark.Value) (string, error)

AsString converts a starlark Value into a string, with outer quotes trimmed

func LoadModule Uses

func LoadModule() (starlark.StringDict, error)

LoadModule loads the bsoup module. Concurrency-safe and idempotent.

func NewSoupNode Uses

func NewSoupNode(root *soup.Root) starlark.Value

NewSoupNode constructs a new SoupNode by cloning each field from the soup.Root

func ParseHTML Uses

func ParseHTML(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)

ParseHTML parses html from a string, and returns it as a SoupNode

type SoupNode Uses

type SoupNode soup.Root

SoupNode extends soup's Root struct with starlark support

func (*SoupNode) Attr Uses

func (n *SoupNode) Attr(name string) (starlark.Value, error)

Attr returns an attribute of a SoupNode

func (*SoupNode) AttrNames Uses

func (n *SoupNode) AttrNames() []string

AttrNames returns all attributes of a SoupNode

func (*SoupNode) Freeze Uses

func (n *SoupNode) Freeze()

Freeze freezes a SoupNode struct, which is already immutable

func (*SoupNode) Hash Uses

func (n *SoupNode) Hash() (uint32, error)

Hash calculates a hash of a SoupNode

func (*SoupNode) String Uses

func (n *SoupNode) String() string

String converts a SoupNode to a string by rendering each node

func (*SoupNode) Truth Uses

func (n *SoupNode) Truth() starlark.Bool

Truth returns whether a SoupNode is non-nil

func (*SoupNode) Type Uses

func (n *SoupNode) Type() string

Type returns the type of SoupNode as string

Package bsoup imports 9 packages (graph) and is imported by 1 packages. Updated 2020-03-23. Refresh now. Tools for package owners.