Monday, April 09, 2012

Category:

Install BeautifulSoup

BeautifulSoup is a library for parsing HTML which makes scraping websites nice and easy.  Unfortunately BeautifulSoup isn't installed with Python...so how do we install it?  Let's see.

Option 1 - "Manual" install

OK, so this isn't very manual but it requires you to download BeautifulSoup and run the setup script.  It's pretty straightforward.
  1. Download BeautifulSoup from here: http://www.crummy.com/software/BeautifulSoup/#Download
  2. Unpack the archive and you get these files: [caption id="attachment_229" align="alignnone" width="300" caption="BeautifulSoup Unpacked"]
    Media_httpjaspermorga_vrcjs
    [/caption]
  3. To install run python setup.py install

Option 2 - EasyInstall

EasyInstall is a module "that lets you automatically download, build, install, and manage Python packages".  Although you have to install EasyInstall itself, it is worth doing to make life easier for yourself when installing modules in the future.  So, the steps are as follows.
  1. EasyInstall is installed as part of them the Python Setup Tools which you can find here: http://pypi.python.org/pypi/setuptools
  2. Install the setup tools package using the clear instructions from above link.  For me on the Mac I ran sudo sh ./setuptools-0.6c11-py2.6.egg
  3. Finally, installing BeautifulSoup is just a matter of running this simple command easy_install BeautifulSoup
Media_httpjaspermorga_egdfg
So, that's all there is to it.