Title: Theory / Unimportant / CS / Programming / Python / Lib / Beautiful soup
Tags: FromInstruction computer_to_instruction automatedNewLineAfterCommaSpace hasNotNewEffectReturnsMeaning
On every note of this deck, unless a note says otherwise:
Page: https://www.crummy.com/software/BeautifulSoup/bs4/doc/#parsing-only-part-of-a-document

Instruction: BeautifulSoup(foo,bar)
Language: Python
Context: BeautifulSoup
Returns: The XML object, from file/string foo, according to parser bar

Name: BeautifulSoup's type
Definition: Tag
Page: https://www.crummy.com/software/BeautifulSoup/bs4/doc/#parsing-only-part-of-a-document
Context: BeautifulSoup
Definition2: NavigableString
Definition4: Comment

Instruction: t.n
Language: Python
Context: BeautifulSoup
Returns: The first tag of name n which is a child of t
Variables: t a tag
n a tag name

Instruction: t[s]
Language: Python
Context: BeautifulSoup
Returns: The value of the attribute s of tag t
Variables: t a tag
s a string

Instruction: t.attrs
Language: Python
Context: BeautifulSoup
Returns: The dictionnary of attributes of t
Variables: t a tag

Instruction: s.replace_with(foo)
Language: Python
Context: BeautifulSoup
Returns: Replace the string of s by foo
Variables: s a navigableString

Instruction: s as a filter
Effect: The filter accepting tags whose name is b
Language: Python
Context: BeautifulSoup
Variables: s a string

Instruction: r as a filter
Effect: The filter accepting elements whose name match r
Language: Python
Context: BeautifulSoup
Variables: r a regexp

Instruction: [filter_1,...,filter_n]
Effect: The filter accepting exactly elements satisfying at least one of the filter filter_i
Language: Python
Context: BeautifulSoup filter

Instruction: True as a filter
Effect: The filter accepting everything
Context: Python BeautifulSoup

Instruction: f as a filter
Effect: The filter accepting an element e iff f(e) return True
Language: Python
Context: BeautifulSoup
Variables: f a function

Instruction: t.find_all(f)
Language: Python
Context: BeautifulSoup
Returns: The list of descendant of t satisfying f
Variables: t a tagf a filter

Instruction: t.find_all(foo=bar)
Language: Python
Context: BeautifulSoup
Returns: The list of descendant of t with an attribute foo with a value satisfying filter bar
Variables: t a tag

Instruction: t.find_all(foo=True)
Language: Python
Context: BeautifulSoup
Returns: The list of descendant of t with an attribute foo
Variables: t a tag

Instruction: t.find_all(
  attrs = {foo_1:bar_1,
  ...,
  foo_n:bar_n,}
)
Language: Python
Context: BeautifulSoup
Returns: The list of descendant of t with attributes foo_i having a value satisfying filter bar_i
Variables: t a tag

Instruction: t.find_all(class_ = f)
Language: Python
Context: BeautifulSoup
Returns: The list of descendant with css class satisfying f
Variables: t a tag
f a filter

Instruction: t.find_all(string = foo)
Language: Python
Context: BeautifulSoup
Returns: The list of descendant wich are strings, satisfying f
Variables: t a tag

Instruction: t.find_all(limit = foo)
Language: Python
Context: BeautifulSoup
Returns: Return a list of at most foo elements
Variables: t a tag

Instruction: t.find_all(recursive = False)
Language: Python
Context: BeautifulSoup
Returns: Return a list containing only children, and no further descendants
Variables: t a tag

Instruction: t.find()
Language: Python
Context: BeautifulSoup
Returns: The first element satisfying the constraints if any, otherwise Nond
Variables: t a tag

Instruction: t.find_parent()
Language: Python
Context: BeautifulSoup
Returns: Similar to find() and find_all() but for ancestors instead of descandant
Variables: t a tag

Instruction: t.find_previous_sibling(s)()
Language: Python
Context: BeautifulSoup
Returns: Similar to find() and find_all() but for siblings after/before t
Variables: t a tag

Instruction: t.find_next(s)()
Language: Python
Context: BeautifulSoup
Returns: Similar to find() and find_all() but for siblings after t in the parsing order
Variables: t a tag

Instruction: t.select(foo)
Language: Python
Context: BeautifulSoup
Returns: Each elements satisfying the css selector foo
Variables: t a BeautifulSoup
foo a css selector

Instruction: t.append(s)
Effect: Add s after the last child of t
Language: Python
Context: BeautifulSoup
Variables: t,s a tag

Instruction: t.insert(foo,s)
Effect: Add s between elements foo and foo+1
Language: Python
Context: BeautifulSoup
Variables: t,s a tag

Instruction: t.insert_before/after(s)
Effect: Insert s in the tree before/after t
Language: Python
Context: BeautifulSoup
Variables: t,s a tag

Instruction: t.clear()
Effect: Remove the content of t
Language: Python
Context: BeautifulSoup
Variables: t a tag

Instruction: t.remove()
Effect: Remove t from its tree
Language: Python
Context: BeautifulSoup
Returns: t
Variables: t a tag

Instruction: t.decompose()
Effect: Remove t from its tree, destroy it and its content
Language: Python
Context: BeautifulSoup
Variables: t a tag

Instruction: t.replace_with(s)
Effect: Replace t in its tree by s
Language: Python
Context: BeautifulSoup
Variables: t,s a tag

Instruction: t.wap(s)
Effect: Add the tag s around t in the tree
Language: Python
Context: BeautifulSoup
Variables: t,s a tag

Instruction: t.unwap()
Effect: Replace t by its content in the tree
Language: Python
Context: BeautifulSoup
Variables: t,s a tag

Instruction: t.prettify()
Language: Python
Context: BeautifulSoup
Returns: A unicode string representing t, with a tag by line
Variables: t a tag

Instruction: str(t)
Language: Python
Context: BeautifulSoup
Returns: A unicode string representing t, without newline nor indentation
Variables: t a tag

Instruction: t.prettify(formatter = "foo")
Language: Python
Context: BeautifulSoup
Returns: t.prettify(), where strings are printed according to the formatter rules foo
Variables: t a tag

Instruction: t.get_text()
Language: Python
Context: BeautifulSoup
Returns: All the text in descendant of t, concatenated
Variables: t a tag

Instruction: t.get_text(foo)
Language: Python
Context: BeautifulSoup
Returns: All the text in descendant of t, concatenated with foo as separator
Variables: t a tag

Instruction: t.get_text(strip=True)
Language: Python
Context: BeautifulSoup
Returns: All the text in descendant of t, stripped and concatenated
Variables: t a tag

Instruction: t == s
Language: Python
Context: BeautifulSoup
Returns: Whether t and s represents the same HTML/XML markup. Independently of their position in the tree
Variables: t,s a tag

Instruction: t is s
Language: Python
Context: BeautifulSoup
Returns: Whether t and s represents the same element in the tree
Variables: t,s a tag

Instruction: BeautifulSoup(
  x,
  parse_only = foo
)
Language: Python
Context: BeautifulSoup
Returns: Similar to BeautifulSoup(  x), but returning only the part satisfying filter foo
Variables: x some XML value

Instruction: Diagnose(x)
Effect: print out a report showing you how different parsers handle the document, and tell you if you’re missing a parser that Beautiful Soup could be using
Language: Python
Context: BeautifulSoup
Variables: x a XML document

Instruction: s.new_tag(foo)
Page: https://www.crummy.com/software/BeautifulSoup/bs4/doc/#contents-and-children
Language: Python
Returns: A new tag, without parents, with name foo
Variables: s a BeautifulSoup

Instruction: t.find_previous(s)()
Language: Python
Context: BeautifulSoup
Returns: Similar to find() and find_all() but for siblings before t in the parsing order
Variables: t a tag

Instruction: t.find_next_sibling(s)()
Language: Python
Context: BeautifulSoup
Returns: Similar to find() and find_all() but for siblings after t
Variables: t a tag