- A Python Book A Python Book: Beginning Python, Advanced Python, and Python Exercises Author: Dave Kuhlman Contact: dkuhlman@davekuhlman.org.
- LXML is a lightweight HTML parser even the most popular web scraping framework (Scrapy) is built on the top of LXML, BeautifulSoup is a little bit overloaded with the number of functions exposed to us, it has more functions to use, yes that's right! However in Web Scraping most of the time we use XPath and CSS Selectors to navigate and select.
Appleās Mac OS comes with python 2.7 installed by default. Perhaps you may want to use python 3.x.x on your machine and also use pip for package management with python 3.x.x.
The easiest way to achieve this is by:
NOTE: This tutorial does not useVirtual Environments like virtualenv
or pyenv
to manage various python
versions
Import Lxml Python
Even if you have a 64bit computer, if you installed a 32bit version of Python you must install the 32bit version of pywin32. To determine what version of Python you have, just start Python and look at the first line of the banner. A 32bit build will look something like: Python 2.7.2+.
1. Installing python3
- Follow this link and download the latest
python3
OS X
package - Run the package and follow the steps to install
python3
on your computer. - Once the installation is done, on your
Terminal
, run
This will print out the version of python installed on your system. The output should be similar to:
You may verify the installation directory of python
by runningthe following line on the Terminal
.
The prompt should print the install path for python3
. An example output is:
2. Install pip3
:
- Securely download the
get-pip.py
file from this link - From the directory where the file was downloaded to, run the following command in the
Terminal
- Once the installation completes you should see the prompt print message similar to this
- Verify the installation of
pip3
by running the following on theTerminal
This should return the install location of pip3
.
- To install
python3
packages usingpip3
, run
Remember to replace packageName
with the appropriate package name for your case.
Python Install Lxml
Happy Pythoning!