install BeautifulSoup

前端 未结 3 1675
萌比男神i
萌比男神i 2020-12-20 06:14

im running python 3.1.2 on my ubuntu 10.04

which version of BeautifulSoup i need to install and how?

i already download version 3.2 and run sudo pytho

3条回答
  •  南方客
    南方客 (楼主)
    2020-12-20 06:44

    I followed these steps to install beautifulsoup4 for HTML parsing.

    • Download the Beautiful Soup 4 source tarball and install it with

      $ python3 setup.py install
      
    • After that enter your python3 console

      $ import bs4
      $ from bs4 import BeautifulSoup
      

    The first statement will work while the second will fail. You have to change BeautifulSoup module into python3 format with the help of this command.

    $ 2to3 -w bs4
    

    3 After that you can run the test again, and everything will work fine.

提交回复
热议问题