- The Prettify () method of the BS4 library:
- For Chinese HTML code, you can also print directly:
Method of HTML content lookup based on BS4 library
- <>.find_all (Name,attrs,recursive,string,**kwargs): Returns a list type that stores the results of a lookup
- Name: Retrieves a string for the label name.
where (Import re) is the import of the regular expression library.
- Attrs: A string that retrieves the value of a tag property, which can be indexed for attribute retrieval.
- Recursive: Whether to retrieve all descendants, the default is ture.
- Retrieves a string from the string range in the string:<>...</>.
- Abbreviated form of the Find_all function:
- <tag> (..) Equivalent to <tag>.find_all (..)
- Soup (..) Equivalent to Soup.find_all (..)
- Extension methods for Find_all functions:
- <>.find (): Searches for and returns only one result, string type, same as. Find_all () parameter
- <>.find.parents (): Search in ancestor node, return list type, same as. Find_all parameter
- <>.find.parent (): Returns a result in the ancestor node, the string type, the same. Find_all () parameter
- <>.find_next_siblings (): Search in subsequent parallel nodes, return list type, same. Find_all () parameter
- <>.find.next_sibling (): Returns a result in subsequent parallel nodes, the string type, the same. Find_all () parameter
- <>.find_previous_siblings (): Search in the parallel node of the previous order, return the list type, the same as the. Find_all () parameter
- <>.find_previous_sibling (): Returns a result, string type, and the same. Find_all () parameter in the parallel node of the previous order
HTML content lookup method and HTML formatting and encoding based on BS4 library