Using regular expressions to extract content from web pages is quite cumbersome. Here is a Python library that can extract data from HTML or XML files: Beautiful Soup. It can achieve idiomatic document navigation through your favorite converter. , how to search and modify documents. Beautiful Soup will help you save hours or even days of work. Beautiful Soup 4.2.0 document
The specific application has been clearly described in the official document, here it is No longer. Let me talk about the problems I encountered during installation.
1. Install python3
Download and install python3 from the official website, add the Path variable, and rename the installed python.exe to python3.exe
2. Install pip3
Input:>pip3
Problem prompt: Fatal error in launcher: Unable to create process using '"'
Input:>python3 -m pip install --upgrade pip
Problem prompt :Requirement already up-to-date: pip in c:\users\****\appdata\local\programs\python\python36-32\lib\site-packages
Input: >python3 -m pip install --upgrade pip --force-reinstall
Output:
Input: >pip3 -V
Output: pip 9.0. 1 from c:\users\****\appdata\local\programs\python\python36-32\lib\site-packages (python 3.6)
pip3 installation completed
3. Install BeautifulSoup4
>pip3 install beautifulsoup4
If you want to install with source code, download the source code of BS4, and then install it through setup.py,
Unzip the downloaded compressed package Go to the local computer and use the command to convert it into Python3 code:
Enter \Tools\scripts in the Python installation directory, which contains 2to3.py. Use the command to convert
\Python36-32\Tools\ scripts>python 2to3.py -w C:\Users\****\AppData\Local\Programs\Python\Python36-32\beautifulsoup4-4.6.0
Use the command prompt to enter the decompression of BS4 directory, start the installation:
>python setup.py install
4. Install the parser:
>pip3 install lxml
> pip3 install html5lib
The installation is complete! It's time to start testing.
There are a lot of BeautifulSoup3 and Python2 codes on the Internet, and various problems will arise when testing them against the demos given. It is recommended to refer directly to the official documentation when learning new content.
The above is the detailed content of Python3+BeautifulSoup4 installation example tutorial. For more information, please follow other related articles on the PHP Chinese website!