Using XPath in Python inevitably requires pouring into the lxml module.
But one of the main problems python faces now is that he has two mainstream versions 2.7 and 3.4
2.7 is a relatively stable version, and many modules are very well supported on 2.7.
3.4 Relatively speaking, I think more standard and normalization, such as the default precision division, as well as print brackets and so on.
But the 3.4 drawback is the support of some modules is not very good, such as: Scrapy,lxml.
I use the Python3.4 in the PIP directly installed lxml will report a compiler error, this problem may be improved in subsequent releases, but a feasible solution is to download the installation lxml compiled version , thus skipping the compilation process.
Download link
After downloading, switch to the appropriate directory to use pip install 文件名
This makes it possible to use lxml in Python.
Ps:
- A small flaw, that is no lxml source, if you use Pycharm and other Ides, then there will be a lack of code hints.
- Although the problem of lxml when installing Scrapy was resolved, the scrapy itself was designed to be used only at 2.7 in the current version (1.0.1).
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Python 3.4 Install lxml