📅  最后修改于: 2023-12-03 15:33:58.447000             🧑  作者: Mango
In this guide, we'll cover how to install the Beautiful Soup 4 library (BS4) for Python.
Before you begin, make sure you have Python 3 installed on your computer. You can download Python 3 from the official website (https://www.python.org/downloads/).
Once you have Python 3 installed, you can install BS4 using pip. Open a terminal (or command prompt on Windows) and type:
pip install beautifulsoup4
This will download and install the latest version of BS4.
To verify that BS4 is installed, open a Python shell by typing python
in the terminal. Then, import the BeautifulSoup class and print its version:
from bs4 import BeautifulSoup
print(BeautifulSoup.__version__)
This should print the version number of BS4.
Installing BS4 is a simple process that can be done in just a few steps with the help of pip. Now, you can use the BS4 library to parse HTML and XML documents in Python.